@tarojs/plugin-mini-ci 3.3.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/README.md ADDED
@@ -0,0 +1,232 @@
1
+ # `@taro/plugin-mini-ci`
2
+
3
+ > Taro 小程序端构建后支持CI(持续集成)的插件, 支持构建完毕后自动打开小程序开发这个工具、上传作为体验版、生成预览二维码. 目前暂时仅支持微信、字节、支付宝、百度小程序
4
+
5
+ ## 使用
6
+
7
+ ### 安装
8
+ ```
9
+ npm i @taro/plugin-mini-ci -D
10
+ ```
11
+
12
+ ### 使用插件
13
+ `/config/index.js`
14
+
15
+ ```js
16
+ // 示例, 如果你使用 `vs code` 作为开发工具, 你还可以使用注释的语法引入插件包含的声明文件,可获得类似于typescript的友好提示
17
+ /**
18
+ * @typedef { import("@tarojs/plugin-mini-ci").CIOptions } CIOptions
19
+ * @type {CIOptions}
20
+ */
21
+ const CIPluginOpt = {
22
+ weapp: {
23
+ appid: "微信小程戏appid",
24
+ privateKeyPath: "密钥文件相对项目根目录的相对路径,例如 key/private.appid.key"
25
+ },
26
+ tt: {
27
+ email: "字节小程序邮箱",
28
+ password: "字节小程序密码"
29
+ },
30
+ alipay: {
31
+ appId: "支付宝小程序appId",
32
+ toolId: "工具id",
33
+ privateKeyPath: "密钥文件相对项目根目录的相对路径,例如 key/pkcs8-private-pem"
34
+ },
35
+ swan: {
36
+ token: "鉴权需要的token令牌"
37
+ },
38
+ // 版本号
39
+ version: "1.0.0",
40
+ // 版本发布描述
41
+ desc: "版本描述"
42
+ }
43
+ const config = {
44
+ plugins: [
45
+ [ "@tarojs/plugin-mini-ci", CIPluginOpt ]
46
+ ]
47
+ }
48
+ ```
49
+
50
+ ### 配置命令
51
+
52
+ `package.json` 的 `scripts` 字段使用命令参数
53
+
54
+ ```json
55
+ {
56
+ "scripts": {
57
+ // 构建完后自动 “打开开发者工具”
58
+ "build:weapp": "taro build --type weapp --open",
59
+ // 构建完后自动“上传代码作为体验版”
60
+ "build:weapp:upload": "taro build --type weapp --upload",
61
+ // 构建完后自动 “上传代码作为开发版并生成预览二维码”
62
+ "build:weapp:preview": "taro build --type weapp --preview"
63
+ },
64
+ "taroConfig": {
65
+ "version": "1.0.0",
66
+ "desc": "上传描述"
67
+ }
68
+ }
69
+ ```
70
+ 由上面的示例可知,插件为taro cli命令扩展了3个选项:
71
+
72
+ - --open
73
+ 打开开发者工具,类似于网页开发中自动打开谷歌浏览器
74
+ - --upload
75
+ 上传代码作为体验版
76
+ - --preview
77
+ 上传代码作为开发版并生成预览二维码
78
+
79
+ 此3个选项在一条命令里不能同时使用
80
+
81
+ ## API
82
+
83
+
84
+ ### 插件配置
85
+
86
+ | 参数 | 类型 | 说明 |
87
+ | :--- | :--- | :--- |
88
+ | weapp | Object | 微信小程序CI配置 |
89
+ | tt | Object | 头条小程序配置 |
90
+ | alipay | Object | 支付宝小程序配置 |
91
+ | swan | Object | 百度小程序配置 |
92
+ | version | string | 上传版本号,不传时默认读取package.json下的taroConfig下的version字段 |
93
+ | desc | string | 上传时的描述信息,不传时默认读取package.json下的taroConfig下的desc字段 |
94
+
95
+ ### 微信小程序CI配置
96
+ | 参数 | 类型 | 说明 |
97
+ | :--- | :--- | :--- |
98
+ | appid | string | 小程序/小游戏项目的 appid |
99
+ | privateKeyPath | string | 私钥文件在项目中的相对路径,在获取项目属性和上传时用于鉴权使用|
100
+ | devToolsInstallPath | string | 微信开发者工具安装路径,如果你安装微信开发者工具时选的默认路径,则不需要传入此参数 |
101
+ | projectPath | string | 上传的小程序的路径(默认取的 outputPath ) |
102
+ | ignores | string[] | 上传需要排除的目录(选填) |
103
+
104
+ 官方CI文档[点这里](https://developers.weixin.qq.com/miniprogram/dev/devtools/ci.html)
105
+
106
+ ### 头条小程序CI配置
107
+
108
+ | 参数 | 类型 | 说明 |
109
+ | :--- | :--- | :--- |
110
+ | email | string | 字节小程序邮箱 |
111
+ | password | string | 字节小程序密码 |
112
+
113
+ 官方CI文档[点这里](https://microapp.bytedance.com/docs/zh-CN/mini-app/develop/developer-instrument/development-assistance/ide-order-instrument)
114
+
115
+ ### 支付宝小程序CI配置
116
+
117
+ | 参数 | 类型 | 说明 |
118
+ | :--- | :--- | :--- |
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) |
123
+
124
+ ```
125
+ 终端类型值及其含义:
126
+
127
+ alipay: 支付宝
128
+
129
+ ampe:AMPE
130
+
131
+ amap:高德
132
+
133
+ genie:天猫精灵
134
+
135
+ alios:ALIOS
136
+
137
+ uc:UC
138
+
139
+ quark:夸克
140
+
141
+ taobao:淘宝
142
+
143
+ koubei:口碑
144
+
145
+ alipayiot:IoT
146
+
147
+ cainiao:菜鸟
148
+
149
+ alihealth:阿里健康
150
+ ```
151
+
152
+ 官方CI文档[点这里](https://opendocs.alipay.com/mini/miniu/api)
153
+
154
+ ### 百度小程序CI配置
155
+
156
+ | 参数 | 类型 | 说明 |
157
+ | :--- | :--- | :--- |
158
+ | token | string | 有该小程序发布权限的登录密钥 |
159
+ | minSwanVersion | string | 最低基础库版本, 不传默认为 3.350.6 |
160
+
161
+ 官方CI文档[点这里](https://smartprogram.baidu.com/docs/develop/devtools/commandtool/)
162
+
163
+ ### ts 接口描述
164
+ ```ts
165
+ export interface IOptions {
166
+ version?: string;
167
+ desc?: string;
168
+ weapp?: WeappConfig;
169
+ tt?: TTConfig;
170
+ alipay?: AlipayConfig;
171
+ swan?: SwanConfig;
172
+ }
173
+
174
+ /** 微信小程序配置 */
175
+ export interface WeappConfig {
176
+ /** 小程序/小游戏项目的 appid */
177
+ appid: string;
178
+ /** 私钥,在获取项目属性和上传时用于鉴权使用(必填) */
179
+ privateKeyPath: string;
180
+ /** 微信开发者工具安装路径 */
181
+ devToolsInstallPath?: string;
182
+ /** 上传的小程序的路径(默认 outputPath ) */
183
+ projectPath?: string;
184
+ /** 类型,默认miniProgram 小程序 */
185
+ type?: ProjectType;
186
+ /** 上传需要排除的目录 */
187
+ ignores?: Array<string>;
188
+ }
189
+
190
+ /** 头条小程序配置 */
191
+ export interface TTConfig {
192
+ email: string;
193
+ password: string;
194
+ }
195
+
196
+ /** 终端类型 */
197
+ export type ClientType =
198
+ /** 支付宝 */'alipay' |
199
+ /** AMPE */'ampe' |
200
+ /** 高德 */'amap' |
201
+ /** 天猫精灵 */'genie'|
202
+ /** ALIOS */ 'alios'|
203
+ /** UC */'uc'|
204
+ /** 夸克 */ 'quark'|
205
+ /** 淘宝 */ 'taobao'|
206
+ /** 口碑 */'koubei' |
207
+ /** loT */'alipayiot'|
208
+ /** 菜鸟 */'cainiao' |
209
+ /** 阿里健康 */ 'alihealth'
210
+
211
+ /** 支付宝系列小程序配置 */
212
+ export interface AlipayConfig {
213
+ /** 小程序appId */
214
+ appId: string;
215
+ /** 工具id */
216
+ toolId: string;
217
+ /** 工具私钥 */
218
+ privateKey: string;
219
+ /** 服务代理地址(可选) */
220
+ proxy?: string;
221
+ /** 上传的终端, 默认alipay */
222
+ clientType?: ClientType;
223
+ }
224
+
225
+ /** 百度小程序配置 */
226
+ export interface SwanConfig {
227
+ /** 有该小程序发布权限的登录密钥 */
228
+ token: string;
229
+ /** 最低基础库版本, 不传默认为 3.350.6 */
230
+ minSwanVersion?: string;
231
+ }
232
+ ```
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ module.exports = require('./dist/index.js').default
2
+ module.exports.default = module.exports
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@tarojs/plugin-mini-ci",
3
+ "version": "3.3.7",
4
+ "description": "Taro 小程序端构建后支持CI(持续集成)的插件",
5
+ "keywords": [
6
+ "Taro",
7
+ "CI/CD"
8
+ ],
9
+ "author": "bigMeow <running@vip.163.com>",
10
+ "homepage": "https://github.com/NervJS/taro#readme",
11
+ "license": "MIT",
12
+ "main": "index.js",
13
+ "typings": "types/index.d.ts",
14
+ "files": [
15
+ "dist",
16
+ "index.js",
17
+ "types"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/NervJS/taro.git"
22
+ },
23
+ "scripts": {
24
+ "build": "tsc",
25
+ "dev": "tsc -w"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/NervJS/taro/issues"
29
+ },
30
+ "dependencies": {
31
+ "minimist": "^1.2.5",
32
+ "miniprogram-ci": "^1.6.1",
33
+ "miniu": "^1.20.1",
34
+ "qrcode-terminal": "^0.12.0",
35
+ "shelljs": "^0.8.4",
36
+ "swan-toolkit": "^3.5.58",
37
+ "tt-ide-cli": "^0.0.24"
38
+ },
39
+ "devDependencies": {
40
+ "@tarojs/service": "^3.3.7"
41
+ }
42
+ }
@@ -0,0 +1,8 @@
1
+ import BaseCI from './BaseCi';
2
+ /** 文档地址: https://opendocs.alipay.com/mini/miniu/api */
3
+ export default class AlipayCI extends BaseCI {
4
+ protected _init(): void;
5
+ open(): void;
6
+ upload(): Promise<void>;
7
+ preview(): Promise<void>;
8
+ }
@@ -0,0 +1,91 @@
1
+ import { IPluginContext } from '@tarojs/service';
2
+ export declare type ProjectType = 'miniProgram' | 'miniGame' | 'miniProgramPlugin' | 'miniGamePlugin';
3
+ /** 微信小程序配置 */
4
+ export interface WeappConfig {
5
+ /** 小程序/小游戏项目的 appid */
6
+ appid: string;
7
+ /** 私钥,在获取项目属性和上传时用于鉴权使用(必填) */
8
+ privateKeyPath: string;
9
+ /** 微信开发者工具安装路径 */
10
+ devToolsInstallPath?: string;
11
+ /** 上传的小程序的路径(默认 outputPath ) */
12
+ projectPath?: string;
13
+ /** 类型,默认miniProgram 小程序 */
14
+ type?: ProjectType;
15
+ /** 上传需要排除的目录 */
16
+ ignores?: Array<string>;
17
+ }
18
+ /** 头条小程序配置 */
19
+ export interface TTConfig {
20
+ /** 绑定的邮箱账号 */
21
+ email: string;
22
+ /** 密码 */
23
+ password: string;
24
+ }
25
+ /** 终端类型 */
26
+ export declare type ClientType =
27
+ /** 支付宝 */ 'alipay' |
28
+ /** AMPE */ 'ampe' |
29
+ /** 高德 */ 'amap' |
30
+ /** 天猫精灵 */ 'genie' |
31
+ /** ALIOS */ 'alios' |
32
+ /** UC */ 'uc' |
33
+ /** 夸克 */ 'quark' |
34
+ /** 淘宝 */ 'taobao' |
35
+ /** 口碑 */ 'koubei' |
36
+ /** loT */ 'alipayiot' |
37
+ /** 菜鸟 */ 'cainiao' |
38
+ /** 阿里健康 */ 'alihealth';
39
+ /** 支付宝系列小程序配置 */
40
+ export interface AlipayConfig {
41
+ /** 小程序appId */
42
+ appId: string;
43
+ /** 工具id */
44
+ toolId: string;
45
+ /** 私钥相对路径 */
46
+ privateKeyPath: string;
47
+ /** 服务代理地址(可选) */
48
+ proxy?: string;
49
+ /** 上传的终端, 默认alipay */
50
+ clientType?: ClientType;
51
+ }
52
+ /** 百度小程序配置 */
53
+ export interface SwanConfig {
54
+ /** 有该小程序发布权限的登录密钥 */
55
+ token: string;
56
+ /** 最低基础库版本, 不传默认为 3.350.6 */
57
+ minSwanVersion?: string;
58
+ }
59
+ export interface CIOptions {
60
+ /** 发布版本号,默认取 package.json 文件的 taroConfig.version 字段 */
61
+ version: string;
62
+ /** 版本发布描述, 默认取 package.json 文件的 taroConfig.desc 字段 */
63
+ desc: string;
64
+ /** 微信小程序CI配置, 官方文档地址:https://developers.weixin.qq.com/miniprogram/dev/devtools/ci.html */
65
+ weapp?: WeappConfig;
66
+ /** 头条小程序配置, 官方文档地址:https://microapp.bytedance.com/docs/zh-CN/mini-app/develop/developer-instrument/development-assistance/ide-order-instrument */
67
+ tt?: TTConfig;
68
+ /** 支付宝系列小程序配置,官方文档地址: https://opendocs.alipay.com/mini/miniu/api */
69
+ alipay?: AlipayConfig;
70
+ /** 百度小程序配置, 官方文档地址:https://smartprogram.baidu.com/docs/develop/devtools/commandtool/ */
71
+ swan?: SwanConfig;
72
+ }
73
+ export default abstract class BaseCI {
74
+ /** taro 插件上下文 */
75
+ protected ctx: IPluginContext;
76
+ /** 传入的插件选项 */
77
+ protected pluginOpts: CIOptions;
78
+ /** 当前要发布的版本号 */
79
+ protected version: string;
80
+ /** 当前发布内容的描述 */
81
+ protected desc: string;
82
+ constructor(ctx: IPluginContext, pluginOpts: CIOptions);
83
+ /** 初始化函数,会被构造函数调用 */
84
+ protected abstract _init(): void;
85
+ /** 打开小程序项目 */
86
+ abstract open(): any;
87
+ /** 上传小程序 */
88
+ abstract upload(): any;
89
+ /** 预览小程序 */
90
+ abstract preview(): any;
91
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 生产二维码输出到控制台
3
+ * @param url 链接地址
4
+ */
5
+ export default function generateQrCode(url: string): void;
@@ -0,0 +1,8 @@
1
+ import BaseCI from './BaseCi';
2
+ export default class SwanCI extends BaseCI {
3
+ private swanBin;
4
+ protected _init(): void;
5
+ open(): void;
6
+ upload(): Promise<void>;
7
+ preview(): Promise<void>;
8
+ }
@@ -0,0 +1,8 @@
1
+ import BaseCI from './BaseCi';
2
+ export default class TTCI extends BaseCI {
3
+ _init(): Promise<void>;
4
+ _beforeCheck(): Promise<any>;
5
+ open(): void;
6
+ preview(): Promise<void>;
7
+ upload(): Promise<void>;
8
+ }
@@ -0,0 +1,10 @@
1
+ import BaseCI from './BaseCi';
2
+ export default class WeappCI extends BaseCI {
3
+ private instance;
4
+ /** 微信开发者安装路径 */
5
+ private devToolsInstallPath;
6
+ _init(): void;
7
+ open(): Promise<void>;
8
+ preview(): Promise<void>;
9
+ upload(): Promise<void>;
10
+ }
@@ -0,0 +1,5 @@
1
+ import { IPluginContext } from '@tarojs/service';
2
+ import { CIOptions } from './BaseCi';
3
+ export { CIOptions } from './BaseCi';
4
+ declare const _default: (ctx: IPluginContext, pluginOpts: CIOptions) => void;
5
+ export default _default;