qdmp-cli 0.1.16 → 0.1.18

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
@@ -2,6 +2,9 @@
2
2
 
3
3
  千岛小程序开发平台命令行工具
4
4
 
5
+ ## 环境要求
6
+
7
+ 使用 Node.js `22.12+`、`24.11+` 或 `26+`,推荐使用最新 LTS 版本。
5
8
 
6
9
  ## ✨ 功能特性
7
10
  - 项目初始化与模板选择
@@ -53,4 +56,6 @@ qdmp-cli build -t emp //目前仅支持taro类型的emp
53
56
  ```bash
54
57
  qdmp-cli upload
55
58
  qdmp-cli upload -e dev //上传开发环境
56
- ```
59
+ qdmp-cli upload -d "新增订单查询功能" //指定版本描述
60
+ ```
61
+ 直接运行上传命令时,会交互式提示输入选填的版本描述(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(
@@ -166,6 +174,20 @@ export const initConfigAction = async (option) => {
166
174
  error(e.message);
167
175
  }
168
176
  };
177
+ const assertCompilerNodeVersion = (version = process.versions.node) => {
178
+ const [major, minor] = version.split(".").map(Number);
179
+ const supported =
180
+ (major === 22 && minor >= 12) ||
181
+ (major === 24 && minor >= 11) ||
182
+ major >= 26;
183
+
184
+ if (!supported) {
185
+ throw new Error(
186
+ `当前 Node.js ${version} 不受 EMP 编译器支持,请使用 Node.js 22.12+、24.11+ 或 26+`,
187
+ );
188
+ }
189
+ };
190
+
169
191
  export const buildAction = async () => {
170
192
  try {
171
193
  const qdmpJsonPath = `${process.cwd()}/qdmp.json`;
@@ -176,6 +198,7 @@ export const buildAction = async () => {
176
198
  const config = JSON.parse(fs.readFileSync(qdmpJsonPath, "utf8"));
177
199
  switch (config.loader) {
178
200
  case "EMP":
201
+ assertCompilerNodeVersion();
179
202
  info("开始构建...");
180
203
  const buildResult = shell.exec("npm run build");
181
204
  if (buildResult.code !== 0) {
@@ -204,7 +227,7 @@ export const buildAction = async () => {
204
227
  );
205
228
  } catch (e) {
206
229
  throw new Error(
207
- "dmcc 构建失败,请保证 npm run build 产物是一个标准的微信小程序",
230
+ `EMP 编译器执行失败,请根据上方原始日志排查依赖或构建产物:${e?.message || "未知错误"}`,
208
231
  );
209
232
  }
210
233
  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);