qdmp-cli 0.1.16 → 0.1.17

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
@@ -53,4 +53,6 @@ qdmp-cli build -t emp //目前仅支持taro类型的emp
53
53
  ```bash
54
54
  qdmp-cli upload
55
55
  qdmp-cli upload -e dev //上传开发环境
56
- ```
56
+ qdmp-cli upload -d "新增订单查询功能" //指定版本描述
57
+ ```
58
+ 直接运行上传命令时,会交互式提示输入选填的版本描述(200字以内)。
package/actions.js CHANGED
@@ -5,7 +5,10 @@ import { download } from "./utils/gitClone.js";
5
5
  import { printLogo } from "./utils/logHandler.js";
6
6
  import chalk from "chalk";
7
7
  import table from "table";
8
- import { inquirerAccountPassword } from "./utils/interactive.js";
8
+ import {
9
+ inquirerAccountPassword,
10
+ inquirerVersionDescription,
11
+ } from "./utils/interactive.js";
9
12
  import { login, getUserInfo } from "./api.js";
10
13
  import fs from "fs";
11
14
  import path from "path";
@@ -110,6 +113,11 @@ export async function uploadAction(option) {
110
113
  if (!remoteApp) {
111
114
  error("未找到应用,请检查appId是否正确");
112
115
  }
116
+ const description = option.description?.trim()
117
+ ?? (process.stdin.isTTY ? await inquirerVersionDescription() : "");
118
+ if (Array.from(description).length > 200) {
119
+ error("版本描述不能超过200字");
120
+ }
113
121
  const code = +remoteApp.latest + 1;
114
122
  const uploadPath = getUploadPath(appId, code);
115
123
  const url = `https://crane.qiandaocdn.com/${uploadPath}`;
@@ -131,7 +139,7 @@ export async function uploadAction(option) {
131
139
  error("上传链接不可用,请检查网络是否正常");
132
140
  }
133
141
  // 更新远端版本信息;
134
- await uploadVersion(appId, url, option.env);
142
+ await uploadVersion(appId, url, option.env, description);
135
143
  // 清理工作文件夹;
136
144
  await cleanWorkSpaceFolder();
137
145
  success(
package/api.js CHANGED
@@ -184,9 +184,20 @@ export const getAppInfo = async (appId, env = "prod") => {
184
184
  * 更新版本
185
185
  * @params {string} appId - appId
186
186
  * @params {string} downloadUrl - 上传链接
187
+ * @params {string} env - 环境
188
+ * @params {string} description - 版本描述
187
189
  */
188
- export const uploadVersion = async (appId, downloadUrl, env = "prod") => {
190
+ export const uploadVersion = async (
191
+ appId,
192
+ downloadUrl,
193
+ env = "prod",
194
+ description = "",
195
+ ) => {
189
196
  try {
197
+ const normalizedDescription = description.trim();
198
+ if (Array.from(normalizedDescription).length > 200) {
199
+ throw new Error("版本描述不能超过200字");
200
+ }
190
201
  const result = await request(
191
202
  "/mp/v1/platform/version/update",
192
203
  {
@@ -194,6 +205,9 @@ export const uploadVersion = async (appId, downloadUrl, env = "prod") => {
194
205
  body: JSON.stringify({
195
206
  appId,
196
207
  downloadUrl,
208
+ ...(normalizedDescription
209
+ ? { description: normalizedDescription }
210
+ : {}),
197
211
  }),
198
212
  },
199
213
  env
package/index.js CHANGED
@@ -67,5 +67,6 @@ program
67
67
  .command("upload")
68
68
  .description("上传项目")
69
69
  .option("-e, --env <env>", "当前环境")
70
+ .option("-d, --description <description>", "版本描述(选填,200字以内)")
70
71
  .action(uploadAction);
71
72
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qdmp-cli",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "qdmp-cli",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -34,3 +34,21 @@ export const inquirerAccountPassword = async (message) => {
34
34
  ]);
35
35
  return { account, password };
36
36
  };
37
+
38
+ /**
39
+ * 输入版本描述
40
+ * @returns {Promise<string>} 版本描述
41
+ */
42
+ export const inquirerVersionDescription = async () => {
43
+ const { description } = await inquirer.prompt([
44
+ {
45
+ type: "input",
46
+ name: "description",
47
+ message: "请输入版本描述(选填,200字以内)",
48
+ validate(value) {
49
+ return Array.from(value.trim()).length <= 200 || "版本描述不能超过200字";
50
+ },
51
+ },
52
+ ]);
53
+ return description.trim();
54
+ };