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 +3 -1
- package/actions.js +10 -2
- package/api.js +15 -1
- package/index.js +1 -0
- package/package.json +1 -1
- package/utils/interactive.js +18 -0
package/README.md
CHANGED
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 {
|
|
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 (
|
|
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
package/package.json
CHANGED
package/utils/interactive.js
CHANGED
|
@@ -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
|
+
};
|