@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/dist/TTCI.js CHANGED
@@ -1,139 +1,113 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  /* eslint-disable no-console */
4
+ const cp = require("child_process");
5
+ const fs = require("fs");
4
6
  const path = require("path");
5
7
  const BaseCi_1 = require("./BaseCi");
6
- const npm_1 = require("./utils/npm");
7
- const qrcode_1 = require("./utils/qrcode");
8
+ const QRCode_1 = require("./QRCode");
8
9
  class TTCI extends BaseCi_1.default {
9
- init() {
10
- const { chalk, printLog, processTypeEnum } = this.ctx.helper;
10
+ async _init() {
11
11
  if (this.pluginOpts.tt == null) {
12
- printLog("error" /* processTypeEnum.ERROR */, chalk.red(('请为"@tarojs/plugin-mini-ci"插件配置 "tt" 选项')));
13
- process.exit(1);
12
+ throw new Error('请为"@tarojs/plugin-mini-ci"插件配置 "tt" 选项');
14
13
  }
15
14
  try {
16
- // 调试使用版本是: tt-ide-cli@0.1.13
17
- this.tt = (0, npm_1.getNpmPkgSync)('tt-ide-cli', process.cwd());
15
+ this.tt = require('tt-ide-cli');
18
16
  }
19
17
  catch (error) {
20
- printLog("error" /* processTypeEnum.ERROR */, chalk.red('请安装依赖:tt-ide-cli'));
21
- process.exit(1);
18
+ throw new Error('请安装依赖:tt-ide-cli');
22
19
  }
23
20
  }
24
21
  async _beforeCheck() {
25
22
  await this.tt.loginByEmail({
26
23
  email: this.pluginOpts.tt.email,
27
- password: this.pluginOpts.tt.password,
28
- dontSaveCookie: false
24
+ password: this.pluginOpts.tt.password
29
25
  });
26
+ return await this.tt.checkSession();
30
27
  }
31
- async open() {
32
- const { chalk, printLog, processTypeEnum } = this.ctx.helper;
33
- printLog("start" /* processTypeEnum.START */, '启动字节跳动开发者工具...', this.projectPath);
34
- try {
35
- await this.tt.open({
36
- project: {
37
- path: this.projectPath
28
+ open() {
29
+ const { outputPath: projectPath } = this.ctx.paths;
30
+ const { chalk } = this.ctx.helper;
31
+ const isMac = process.platform === 'darwin';
32
+ const IDE_SCHEMA = 'bytedanceide:';
33
+ const openCmd = isMac ? `open ${IDE_SCHEMA}` : `explorer ${IDE_SCHEMA}`;
34
+ if (fs.existsSync(projectPath)) {
35
+ console.log(chalk.green(`open projectPath: ${projectPath}`));
36
+ const openPath = `${openCmd}?path=${projectPath}`;
37
+ cp.exec(openPath, (error) => {
38
+ if (!error) {
39
+ console.log('打开IDE成功', openPath);
40
+ }
41
+ else {
42
+ console.log(chalk.red('打开IDE失败', error));
38
43
  }
39
44
  });
40
- console.log(chalk.green(`打开IDE成功`));
41
45
  }
42
- catch (error) {
43
- printLog("error" /* processTypeEnum.ERROR */, chalk.red('打开IDE失败', error));
46
+ else {
47
+ console.log(chalk.green('open IDE'));
48
+ cp.exec(openCmd, (error) => {
49
+ if (!error) {
50
+ console.log('打开IDE成功');
51
+ }
52
+ else {
53
+ console.log(chalk.red('打开IDE失败', error));
54
+ }
55
+ });
44
56
  }
45
57
  }
46
58
  async preview() {
47
- await this._beforeCheck();
59
+ const isLogin = await this._beforeCheck();
60
+ if (!isLogin)
61
+ return;
48
62
  const { chalk, printLog, processTypeEnum } = this.ctx.helper;
63
+ const { outputPath } = this.ctx.paths;
64
+ const appInfo = JSON.parse(fs.readFileSync(path.join(outputPath, 'app.json'), {
65
+ encoding: 'utf8'
66
+ }));
49
67
  try {
50
68
  printLog("start" /* processTypeEnum.START */, '预览字节跳动小程序');
51
- const previewQrcodePath = path.join(this.projectPath, 'preview.png');
52
69
  const previewResult = await this.tt.preview({
53
70
  project: {
54
- path: this.projectPath
71
+ path: outputPath
55
72
  },
56
- // @ts-ignore
57
73
  page: {
58
- path: ''
74
+ path: appInfo.pages[0]
59
75
  },
60
76
  qrcode: {
61
- format: 'imageFile',
62
- output: previewQrcodePath,
63
- },
64
- copyToClipboard: true,
65
- cache: true
66
- });
67
- console.log(chalk.green(`开发版上传成功 ${new Date().toLocaleString()}\n`));
68
- const qrContent = previewResult.shortUrl;
69
- await (0, qrcode_1.printQrcode2Terminal)(qrContent);
70
- printLog("remind" /* processTypeEnum.REMIND */, `预览二维码已生成,存储在:"${previewQrcodePath}",二维码内容是:${qrContent},过期时间:${new Date(previewResult.expireTime * 1000).toLocaleString()}`);
71
- this.triggerPreviewHooks({
72
- success: true,
73
- data: {
74
- platform: 'tt',
75
- qrCodeContent: qrContent,
76
- qrCodeLocalPath: previewQrcodePath
77
+ format: 'imageSVG',
78
+ options: {
79
+ small: true
80
+ }
77
81
  }
78
82
  });
83
+ (0, QRCode_1.default)(previewResult.shortUrl);
84
+ printLog("generate" /* processTypeEnum.GENERATE */, '二维码已生成,请扫码预览');
79
85
  }
80
86
  catch (error) {
81
- printLog("error" /* processTypeEnum.ERROR */, chalk.red(`上传失败 ${new Date().toLocaleString()} \n${error}`));
82
- this.triggerPreviewHooks({
83
- success: false,
84
- data: {
85
- platform: 'tt',
86
- qrCodeContent: '',
87
- qrCodeLocalPath: ''
88
- },
89
- error: new Error(error)
90
- });
87
+ console.log(chalk.red(`上传失败 ${new Date().toLocaleString()} \n${error.message}`));
91
88
  }
92
89
  }
93
90
  async upload() {
94
- await this._beforeCheck();
91
+ const isLogin = await this._beforeCheck();
92
+ if (!isLogin)
93
+ return;
95
94
  const { chalk, printLog, processTypeEnum } = this.ctx.helper;
95
+ const { outputPath } = this.ctx.paths;
96
96
  try {
97
97
  printLog("start" /* processTypeEnum.START */, '上传代码到字节跳动后台');
98
98
  printLog("remind" /* processTypeEnum.REMIND */, `本次上传版本号为:"${this.version}",上传描述为:“${this.desc}”`);
99
- const uploadQrcodePath = path.join(this.projectPath, 'upload.png');
100
- const uploadResult = await this.tt.upload({
99
+ await this.tt.upload({
101
100
  project: {
102
- path: this.projectPath
103
- },
104
- qrcode: {
105
- format: 'imageFile',
106
- output: uploadQrcodePath,
101
+ path: outputPath
107
102
  },
108
103
  version: this.version,
109
104
  changeLog: this.desc,
110
- needUploadSourcemap: true,
111
- copyToClipboard: false
112
- });
113
- console.log(chalk.green(`体验版版上传成功 ${new Date().toLocaleString()}\n`));
114
- const qrContent = uploadResult.shortUrl;
115
- await (0, qrcode_1.printQrcode2Terminal)(qrContent);
116
- printLog("remind" /* processTypeEnum.REMIND */, `体验版二维码已生成,存储在:"${uploadQrcodePath}",二维码内容是:"${qrContent}", 过期时间:${new Date(uploadResult.expireTime * 1000).toLocaleString()}`);
117
- this.triggerUploadHooks({
118
- success: true,
119
- data: {
120
- platform: 'tt',
121
- qrCodeContent: qrContent,
122
- qrCodeLocalPath: uploadQrcodePath
123
- }
105
+ needUploadSourcemap: true
124
106
  });
107
+ printLog("remind" /* processTypeEnum.REMIND */, '上传完成');
125
108
  }
126
109
  catch (error) {
127
- printLog("error" /* processTypeEnum.ERROR */, chalk.red(`上传失败 ${new Date().toLocaleString()} \n${error}`));
128
- this.triggerUploadHooks({
129
- success: false,
130
- data: {
131
- platform: 'tt',
132
- qrCodeContent: '',
133
- qrCodeLocalPath: ''
134
- },
135
- error: new Error(error)
136
- });
110
+ console.log(chalk.red(`上传失败 ${new Date().toLocaleString()} \n${error.message}`));
137
111
  }
138
112
  }
139
113
  }
package/dist/TTCI.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"TTCI.js","sourceRoot":"","sources":["../src/TTCI.ts"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,6BAA4B;AAE5B,qCAA6B;AAE7B,qCAA2C;AAC3C,2CAAqD;AAErD,MAAqB,IAAK,SAAQ,gBAAM;IAGtC,IAAI;QACF,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAA;QAC5D,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,IAAI,EAAE;YAC9B,QAAQ,sCAAwB,KAAK,CAAC,GAAG,CAAC,CAAC,wCAAwC,CAAC,CAA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A;SACnD;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;SACjF;IACH,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAA;QACzC,IAAI,CAAC,OAAO;YAAE,OAAM;QACpB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAA;QAC5D,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAA;QACrC,IAAI;YACF,QAAQ,sCAAwB,aAAa,CAAC,CAAA;YAC9C,QAAQ,wCAAyB,aAAa,IAAI,CAAC,OAAO,YAAY,IAAI,CAAC,IAAI,GAAG,CAAC,CAAA;YACnF,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;gBACnB,OAAO,EAAE;oBACP,IAAI,EAAE,UAAU;iBACjB;gBACD,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,SAAS,EAAE,IAAI,CAAC,IAAI;gBACpB,mBAAmB,EAAE,IAAI;aAC1B,CAAC,CAAA;YACF,QAAQ,wCAAyB,MAAM,CAAC,CAAA;SACzC;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;SACjF;IACH,CAAC;CACF;AAxGD,uBAwGC"}
package/dist/WeappCI.js CHANGED
@@ -1,29 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  /* eslint-disable no-console */
4
- const crypto = require("crypto");
4
+ const cp = require("child_process");
5
5
  const ci = require("miniprogram-ci");
6
6
  const os = require("os");
7
7
  const path = require("path");
8
- const shell = require("shelljs");
9
8
  const BaseCi_1 = require("./BaseCi");
10
- const qrcode_1 = require("./utils/qrcode");
11
9
  class WeappCI extends BaseCi_1.default {
12
- init() {
13
- const { appPath } = this.ctx.paths;
10
+ _init() {
11
+ const { outputPath, appPath } = this.ctx.paths;
14
12
  const { fs } = this.ctx.helper;
15
13
  if (this.pluginOpts.weapp == null) {
16
14
  throw new Error('请为"@tarojs/plugin-mini-ci"插件配置 "weapp" 选项');
17
15
  }
18
16
  this.devToolsInstallPath = this.pluginOpts.weapp.devToolsInstallPath || (process.platform === 'darwin' ? '/Applications/wechatwebdevtools.app' : 'C:\\Program Files (x86)\\Tencent\\微信web开发者工具');
19
17
  delete this.pluginOpts.weapp.devToolsInstallPath;
20
- const weappConfig = {
21
- type: 'miniProgram',
22
- projectPath: this.projectPath,
23
- appid: this.pluginOpts.weapp.appid,
24
- privateKeyPath: this.pluginOpts.weapp.privateKeyPath,
25
- ignores: this.pluginOpts.weapp.ignores,
26
- };
18
+ const weappConfig = Object.assign({ type: 'miniProgram', projectPath: outputPath, ignores: ['node_modules/**/*'] }, this.pluginOpts.weapp);
27
19
  const privateKeyPath = path.isAbsolute(weappConfig.privateKeyPath) ? weappConfig.privateKeyPath : path.join(appPath, weappConfig.privateKeyPath);
28
20
  if (!fs.pathExistsSync(privateKeyPath)) {
29
21
  throw new Error(`"weapp.privateKeyPath"选项配置的路径不存在,本次上传终止:${privateKeyPath}`);
@@ -32,6 +24,7 @@ class WeappCI extends BaseCi_1.default {
32
24
  }
33
25
  async open() {
34
26
  const { fs, printLog, processTypeEnum, getUserHomeDir } = this.ctx.helper;
27
+ const { appPath } = this.ctx.paths;
35
28
  // 检查安装路径是否存在
36
29
  if (!(await fs.pathExists(this.devToolsInstallPath))) {
37
30
  printLog("error" /* processTypeEnum.ERROR */, '微信开发者工具安装路径不存在', this.devToolsInstallPath);
@@ -41,9 +34,9 @@ class WeappCI extends BaseCi_1.default {
41
34
  const cliPath = path.join(this.devToolsInstallPath, os.platform() === 'win32' ? '/cli.bat' : '/Contents/MacOS/cli');
42
35
  const isWindows = os.platform() === 'win32';
43
36
  // 检查是否开启了命令行
44
- const errMesg = '工具的服务端口已关闭。要使用命令行调用工具,请打开工具 -> 设置 -> 安全设置,将服务端口开启。详细信息: https://developers.weixin.qq.com/miniprogram/dev/devtools/cli.html ';
37
+ const errMesg = '工具的服务端口已关闭。要使用命令行调用工具,请打开工具 -> 设置 -> 安全设置,将服务端口开启。详细信息: https://developers.weixin.qq.com/miniprogram/dev/devtools/cli.html';
45
38
  const installPath = isWindows ? this.devToolsInstallPath : `${this.devToolsInstallPath}/Contents/MacOS`;
46
- const md5 = crypto.createHash('md5').update(installPath).digest('hex');
39
+ const md5 = require('crypto').createHash('md5').update(installPath).digest('hex');
47
40
  const ideStatusFile = path.join(getUserHomeDir(), isWindows
48
41
  ? `/AppData/Local/微信开发者工具/User Data/${md5}/Default/.ide-status`
49
42
  : `/Library/Application Support/微信开发者工具/${md5}/Default/.ide-status`);
@@ -59,58 +52,32 @@ class WeappCI extends BaseCi_1.default {
59
52
  if (!(await fs.pathExists(cliPath))) {
60
53
  printLog("error" /* processTypeEnum.ERROR */, '命令行工具路径不存在', cliPath);
61
54
  }
62
- printLog("start" /* processTypeEnum.START */, '微信开发者工具...', this.projectPath);
63
- shell.exec(`${cliPath} open --project ${this.projectPath}`);
55
+ printLog("start" /* processTypeEnum.START */, '微信开发者工具...');
56
+ cp.exec(`${cliPath} open --project ${appPath}`, (err) => {
57
+ if (err) {
58
+ printLog("error" /* processTypeEnum.ERROR */, err.message);
59
+ }
60
+ });
64
61
  }
65
62
  async preview() {
66
63
  const { chalk, printLog, processTypeEnum } = this.ctx.helper;
67
64
  try {
68
65
  printLog("start" /* processTypeEnum.START */, '上传开发版代码到微信后台并预览');
69
- const previewQrcodePath = path.join(this.projectPath, 'preview.jpg');
70
66
  const uploadResult = await ci.preview({
71
67
  project: this.instance,
72
68
  version: this.version,
73
69
  desc: this.desc,
74
- onProgressUpdate: undefined,
75
- robot: this.pluginOpts.weapp.robot,
76
- qrcodeFormat: 'image',
77
- qrcodeOutputDest: previewQrcodePath
70
+ onProgressUpdate: undefined
78
71
  });
79
72
  if (uploadResult.subPackageInfo) {
80
73
  const allPackageInfo = uploadResult.subPackageInfo.find((item) => item.name === '__FULL__');
81
74
  const mainPackageInfo = uploadResult.subPackageInfo.find((item) => item.name === '__APP__');
82
75
  const extInfo = `本次上传${allPackageInfo.size / 1024}kb ${mainPackageInfo ? ',其中主包' + mainPackageInfo.size + 'kb' : ''}`;
83
- console.log(chalk.green(`开发版上传成功 ${new Date().toLocaleString()} ${extInfo}\n`));
84
- }
85
- let qrContent;
86
- try {
87
- qrContent = await (0, qrcode_1.readQrcodeImageContent)(previewQrcodePath);
88
- await (0, qrcode_1.printQrcode2Terminal)(qrContent);
89
- printLog("remind" /* processTypeEnum.REMIND */, `预览二维码已生成,存储在:"${previewQrcodePath}",二维码内容是:${qrContent}`);
90
- }
91
- catch (error) {
92
- printLog("error" /* processTypeEnum.ERROR */, chalk.red(`获取预览二维码失败:${error.message}`));
76
+ console.log(chalk.green(`上传成功 ${new Date().toLocaleString()} ${extInfo}`));
93
77
  }
94
- this.triggerPreviewHooks({
95
- success: true,
96
- data: {
97
- platform: 'weapp',
98
- qrCodeContent: qrContent,
99
- qrCodeLocalPath: previewQrcodePath
100
- }
101
- });
102
78
  }
103
79
  catch (error) {
104
- printLog("error" /* processTypeEnum.ERROR */, chalk.red(`上传失败 ${new Date().toLocaleString()} \n${error.message}`));
105
- this.triggerPreviewHooks({
106
- success: false,
107
- data: {
108
- platform: 'weapp',
109
- qrCodeContent: '',
110
- qrCodeLocalPath: ''
111
- },
112
- error
113
- });
80
+ console.log(chalk.red(`上传失败 ${new Date().toLocaleString()} \n${error.message}`));
114
81
  }
115
82
  }
116
83
  async upload() {
@@ -122,58 +89,17 @@ class WeappCI extends BaseCi_1.default {
122
89
  project: this.instance,
123
90
  version: this.version,
124
91
  desc: this.desc,
125
- onProgressUpdate: undefined,
126
- robot: this.pluginOpts.weapp.robot
92
+ onProgressUpdate: undefined
127
93
  });
128
94
  if (uploadResult.subPackageInfo) {
129
95
  const allPackageInfo = uploadResult.subPackageInfo.find((item) => item.name === '__FULL__');
130
96
  const mainPackageInfo = uploadResult.subPackageInfo.find((item) => item.name === '__APP__');
131
97
  const extInfo = `本次上传${allPackageInfo.size / 1024}kb ${mainPackageInfo ? ',其中主包' + mainPackageInfo.size + 'kb' : ''}`;
132
- console.log(chalk.green(`上传成功 ${new Date().toLocaleString()} ${extInfo}\n`));
133
- }
134
- const uploadQrcodePath = path.join(this.projectPath, 'upload.png');
135
- try {
136
- // 体验码规则: https://open.weixin.qq.com/sns/getexpappinfo?appid=xxx&path=入口路径.html#wechat-redirect
137
- const qrContent = `https://open.weixin.qq.com/sns/getexpappinfo?appid=${this.pluginOpts.weapp.appid}#wechat-redirect`;
138
- await (0, qrcode_1.printQrcode2Terminal)(qrContent);
139
- await (0, qrcode_1.generateQrcodeImageFile)(uploadQrcodePath, qrContent);
140
- printLog("remind" /* processTypeEnum.REMIND */, `体验版二维码已生成,存储在:"${uploadQrcodePath}",二维码内容是:"${qrContent}"`);
141
- printLog("remind" /* processTypeEnum.REMIND */, `可能需要您前往微信后台,将当前上传版本设置为“体验版”`);
142
- printLog("remind" /* processTypeEnum.REMIND */, `若本次上传的robot机器人和上次一致,并且之前已经在微信后台设置其为“体验版”,则本次无需再次设置`);
143
- this.triggerUploadHooks({
144
- success: true,
145
- data: {
146
- platform: 'weapp',
147
- qrCodeContent: qrContent,
148
- qrCodeLocalPath: uploadQrcodePath
149
- }
150
- });
151
- }
152
- catch (error) {
153
- // 实际读取二维码时有极小概率会读取失败,待观察
154
- printLog("error" /* processTypeEnum.ERROR */, chalk.red(`体验二维码生成失败:${error.message}`));
155
- this.triggerUploadHooks({
156
- success: true,
157
- data: {
158
- platform: 'weapp',
159
- qrCodeContent: '',
160
- qrCodeLocalPath: uploadQrcodePath
161
- },
162
- error
163
- });
98
+ console.log(chalk.green(`上传成功 ${new Date().toLocaleString()} ${extInfo}`));
164
99
  }
165
100
  }
166
101
  catch (error) {
167
- printLog("error" /* processTypeEnum.ERROR */, chalk.red(`上传失败 ${new Date().toLocaleString()} \n${error.message}`));
168
- this.triggerUploadHooks({
169
- success: false,
170
- data: {
171
- platform: 'weapp',
172
- qrCodeContent: '',
173
- qrCodeLocalPath: ''
174
- },
175
- error
176
- });
102
+ console.log(chalk.red(`上传失败 ${new Date().toLocaleString()} \n${error.message}`));
177
103
  }
178
104
  }
179
105
  }
@@ -1 +1 @@
1
- {"version":3,"file":"WeappCI.js","sourceRoot":"","sources":["../src/WeappCI.ts"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,iCAAgC;AAChC,qCAAoC;AAEpC,yBAAwB;AACxB,6BAA4B;AAC5B,iCAAgC;AAEhC,qCAA8C;AAC9C,2CAAsG;AAEtG,MAAqB,OAAQ,SAAQ,gBAAM;IAKzC,IAAI;QACF,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAA;QAClC,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAA;QAC9B,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,IAAI,IAAI,EAAE;YACjC,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAA;SAC7D;QACD,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,mBAAmB,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC,8CAA8C,CAAC,CAAA;QAChM,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,mBAAmB,CAAA;QAEhD,MAAM,WAAW,GAAG;YAClB,IAAI,EAAE,aAA4B;Y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,IAAI,EAAE,CAAC,cAAc,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC,CAAA;aAC3E;SACF;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;SACjF;IACH,CAAC;CACF;AAlHD,0BAkHC"}
package/dist/index.js CHANGED
@@ -1,42 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const minimist = require("minimist");
4
- const path = require("path");
5
4
  const AlipayCI_1 = require("./AlipayCI");
6
- const DingtalkCI_1 = require("./DingtalkCI");
7
5
  const SwanCI_1 = require("./SwanCI");
8
6
  const TTCI_1 = require("./TTCI");
9
7
  const WeappCI_1 = require("./WeappCI");
10
- var EnumAction;
11
- (function (EnumAction) {
12
- /** 自动打开预览工具 */
13
- EnumAction["open"] = "open";
14
- /** 预览小程序(上传代码,作为“开发版”小程序) */
15
- EnumAction["preview"] = "preview";
16
- /** 上传小程序(上传代码,可设置为“体验版”小程序) */
17
- EnumAction["upload"] = "upload";
18
- })(EnumAction || (EnumAction = {}));
19
- exports.default = (ctx, _pluginOpts) => {
20
- const args = minimist(process.argv.slice(2), {
21
- boolean: ["open" /* EnumAction.open */, "preview" /* EnumAction.preview */, "upload" /* EnumAction.upload */],
22
- string: ['projectPath'],
23
- default: {
24
- projectPath: ''
25
- }
26
- });
27
- const command = args._[0];
28
- // 参数验证,支持传入配置对象、返回配置对象的异步函数
8
+ exports.default = (ctx, pluginOpts) => {
9
+ const onBuildDone = ctx.onBuildComplete || ctx.onBuildFinish;
29
10
  ctx.addPluginOptsSchema((joi) => {
30
- return joi.alternatives().try(joi.function().required(), joi
11
+ return joi
31
12
  .object()
32
13
  .keys({
33
14
  /** 微信小程序上传配置 */
34
15
  weapp: joi.object({
35
16
  appid: joi.string().required(),
17
+ projectPath: joi.string(),
36
18
  privateKeyPath: joi.string().required(),
37
19
  type: joi.string().valid('miniProgram', 'miniProgramPlugin', 'miniGame', 'miniGamePlugin'),
38
- ignores: joi.array().items(joi.string().required()),
39
- robot: joi.number()
20
+ ignores: joi.array().items(joi.string().required())
40
21
  }),
41
22
  /** 字节跳动小程序上传配置 */
42
23
  tt: joi.object({
@@ -44,23 +25,13 @@ exports.default = (ctx, _pluginOpts) => {
44
25
  password: joi.string().required()
45
26
  }),
46
27
  /** 阿里小程序上传配置 */
47
- alipay: joi.alternatives().try(joi.object({
48
- appid: joi.string().required(),
28
+ alipay: joi.object({
29
+ appId: joi.string().required(),
49
30
  toolId: joi.string().required(),
50
31
  privateKeyPath: joi.string().required(),
51
- clientType: joi.string().valid('alipay', 'ampe', 'amap', 'genie', 'alios', 'uc', 'quark', 'health', 'koubei', 'alipayiot', 'cainiao', 'alihealth')
52
- }), joi.object({
53
- appid: joi.string().required(),
54
- toolId: joi.string().required(),
55
- privateKey: joi.string().required(),
56
- clientType: joi.string().valid('alipay', 'ampe', 'amap', 'genie', 'alios', 'uc', 'quark', 'health', 'koubei', 'alipayiot', 'cainiao', 'alihealth')
57
- })),
58
- /** 钉钉小程序配置 */
59
- dd: joi.object({
60
- token: joi.string().required(),
61
- appid: joi.string().required(),
62
- devToolsInstallPath: joi.string(),
63
- projectType: joi.string().valid('dingtalk-personal', 'dingtalk-biz-isv', 'dingtalk-biz', 'dingtalk-biz-custom', 'dingtalk-biz-worktab-plugin')
32
+ proxy: joi.string(),
33
+ project: joi.string(),
34
+ clientType: joi.string().valid('alipay', 'ampe', 'amap', 'genie', 'alios', 'uc', 'quark', 'taobao', 'koubei', 'alipayiot', 'cainiao', 'alihealth')
64
35
  }),
65
36
  /** 百度小程序上传配置 */
66
37
  swan: joi.object({
@@ -68,20 +39,17 @@ exports.default = (ctx, _pluginOpts) => {
68
39
  minSwanVersion: joi.string()
69
40
  }),
70
41
  version: joi.string(),
71
- desc: joi.string(),
72
- projectPath: joi.string()
42
+ desc: joi.string()
73
43
  })
74
- .required());
44
+ .required();
75
45
  });
76
- const doAction = async (platform, action, projectPath) => {
77
- const { printLog, processTypeEnum, fs } = ctx.helper;
78
- if (typeof platform !== 'string') {
79
- printLog("error" /* processTypeEnum.ERROR */, '请传入正确的编译类型!');
80
- process.exit(0);
81
- }
82
- // 可通过异步函数获取插件选项
83
- const pluginOpts = typeof _pluginOpts === 'function' ? await _pluginOpts() : _pluginOpts;
84
- let ci = null;
46
+ onBuildDone(async () => {
47
+ const args = minimist(process.argv.slice(2), {
48
+ boolean: ['open', 'upload', 'preview']
49
+ });
50
+ const { printLog, processTypeEnum } = ctx.helper;
51
+ const platform = ctx.runOpts.options.platform;
52
+ let ci;
85
53
  switch (platform) {
86
54
  case 'weapp':
87
55
  ci = new WeappCI_1.default(ctx, pluginOpts);
@@ -93,74 +61,29 @@ exports.default = (ctx, _pluginOpts) => {
93
61
  case 'iot':
94
62
  ci = new AlipayCI_1.default(ctx, pluginOpts);
95
63
  break;
96
- case 'dd':
97
- ci = new DingtalkCI_1.default(ctx, pluginOpts);
98
- break;
99
64
  case 'swan':
100
65
  ci = new SwanCI_1.default(ctx, pluginOpts);
101
66
  break;
67
+ default:
68
+ break;
102
69
  }
103
70
  if (!ci) {
104
71
  printLog("warning" /* processTypeEnum.WARNING */, `"@tarojs/plugin-mini-ci" 插件暂时不支持 "${platform}" 平台`);
105
72
  return;
106
73
  }
107
- projectPath = projectPath || pluginOpts.projectPath || ctx.paths.outputPath;
108
- projectPath = path.isAbsolute(projectPath) ? projectPath : path.join(ctx.paths.appPath, projectPath);
109
- if (!fs.pathExistsSync(projectPath)) {
110
- printLog("error" /* processTypeEnum.ERROR */, `"projectPath"选项配置的路径不存在:${projectPath}`);
111
- process.exit(0);
112
- }
113
- ci.setProjectPath(projectPath);
114
- ci.init();
115
- switch (action) {
116
- case "open" /* EnumAction.open */:
74
+ switch (true) {
75
+ case args.open:
117
76
  ci.open();
118
77
  break;
119
- case "upload" /* EnumAction.upload */:
78
+ case args.upload:
120
79
  ci.upload();
121
80
  break;
122
- case "preview" /* EnumAction.preview */:
81
+ case args.preview:
123
82
  ci.preview();
124
83
  break;
84
+ default:
85
+ break;
125
86
  }
126
- };
127
- // 构建小程序后执行
128
- if (command === 'build') {
129
- const onBuildDone = ctx.onBuildComplete || ctx.onBuildFinish;
130
- onBuildDone(async () => {
131
- let action = null;
132
- switch (true) {
133
- case args["open" /* EnumAction.open */]:
134
- action = "open" /* EnumAction.open */;
135
- break;
136
- case args["preview" /* EnumAction.preview */]:
137
- action = "preview" /* EnumAction.preview */;
138
- break;
139
- case args["upload" /* EnumAction.upload */]:
140
- action = "upload" /* EnumAction.upload */;
141
- break;
142
- }
143
- if (action) {
144
- await doAction(ctx.runOpts.options.platform, action, args.projectPath);
145
- }
146
- });
147
- }
148
- // 注册独立的命令,可直接上传构建后的代码
149
- ["open" /* EnumAction.open */, "preview" /* EnumAction.preview */, "upload" /* EnumAction.upload */].forEach(action => {
150
- ctx.registerCommand({
151
- name: action,
152
- optionsMap: {
153
- '--type [typeName]': `${action} type, 支持 weapp/swan/alipay/iot/tt/dd`,
154
- '--projectPath': `${action} 目录, 不传默认为配置项 'outputRoot' 配置目录`
155
- },
156
- synopsisList: [
157
- `taro ${action} --type weapp`,
158
- `taro ${action} --type alipay`
159
- ],
160
- async fn({ options }) {
161
- doAction(options.type, action, options.projectPath);
162
- }
163
- });
164
87
  });
165
88
  };
166
89
  //# sourceMappingURL=index.js.map