qdmp-cli 0.1.17 → 0.1.19

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,11 @@
2
2
 
3
3
  千岛小程序开发平台命令行工具
4
4
 
5
+ ## 环境要求
6
+
7
+ 使用 Node.js `22.12+`、`24.11+` 或 `26+`,推荐使用最新 LTS 版本。
8
+
9
+ 使用 NVM 切换 Node.js 后,请在新版本环境中重新全局安装 `qdmp-cli`,避免继续使用旧版本 Node.js 目录中的依赖。
5
10
 
6
11
  ## ✨ 功能特性
7
12
  - 项目初始化与模板选择
package/actions.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  inquirerAccountPassword,
10
10
  inquirerVersionDescription,
11
11
  } from "./utils/interactive.js";
12
- import { login, getUserInfo } from "./api.js";
12
+ import { login, getDeveloperId, getUserInfo } from "./api.js";
13
13
  import fs from "fs";
14
14
  import path from "path";
15
15
  import { createRequire } from "module";
@@ -21,6 +21,7 @@ import {
21
21
  preUpload,
22
22
  cleanWorkSpaceFolder,
23
23
  } from "./utils/common.js";
24
+ import { assertCompilerRuntime } from "./utils/compilerRuntime.js";
24
25
  import { getAppInfo, uploadVersion, uploadApp } from "./api.js";
25
26
 
26
27
  function createProject(appName, template) {
@@ -105,6 +106,7 @@ export const getMyInfoAction = async (option) => {
105
106
 
106
107
  export async function uploadAction(option) {
107
108
  try {
109
+ const did = await getDeveloperId(option.env);
108
110
  const appId = await getAppId(option.env);
109
111
  if (!appId) {
110
112
  error("未授权应用,请在根目录下qdmp.json配置对应的appId");
@@ -139,7 +141,7 @@ export async function uploadAction(option) {
139
141
  error("上传链接不可用,请检查网络是否正常");
140
142
  }
141
143
  // 更新远端版本信息;
142
- await uploadVersion(appId, url, option.env, description);
144
+ await uploadVersion(appId, url, option.env, description, did);
143
145
  // 清理工作文件夹;
144
146
  await cleanWorkSpaceFolder();
145
147
  success(
@@ -184,6 +186,7 @@ export const buildAction = async () => {
184
186
  const config = JSON.parse(fs.readFileSync(qdmpJsonPath, "utf8"));
185
187
  switch (config.loader) {
186
188
  case "EMP":
189
+ await assertCompilerRuntime();
187
190
  info("开始构建...");
188
191
  const buildResult = shell.exec("npm run build");
189
192
  if (buildResult.code !== 0) {
@@ -212,7 +215,7 @@ export const buildAction = async () => {
212
215
  );
213
216
  } catch (e) {
214
217
  throw new Error(
215
- "dmcc 构建失败,请保证 npm run build 产物是一个标准的微信小程序",
218
+ `EMP 编译器执行失败,请根据上方原始日志排查依赖或构建产物:${e?.message || "未知错误"}`,
216
219
  );
217
220
  }
218
221
  success("构建完成");
package/api.js CHANGED
@@ -104,6 +104,23 @@ export const getUserInfo = async (env = "prod") => {
104
104
  throw new Error(error?.message);
105
105
  }
106
106
  };
107
+
108
+ /**
109
+ * 获取当前开发者 DID
110
+ * @returns {Promise<string>} 开发者 DID
111
+ */
112
+ export const getDeveloperId = async (env = "prod") => {
113
+ try {
114
+ const result = await request("/mp/v1/user/me", {}, env);
115
+ const did = result?.data?.did;
116
+ if (!did) {
117
+ throw new Error("未获取到当前开发者 DID,请重新登录");
118
+ }
119
+ return did;
120
+ } catch (error) {
121
+ throw new Error(error?.message);
122
+ }
123
+ };
107
124
  /**
108
125
  * 获取版本包 PostPolicy 直传凭证
109
126
  * @returns {Promise} PostPolicy 参数
@@ -186,12 +203,14 @@ export const getAppInfo = async (appId, env = "prod") => {
186
203
  * @params {string} downloadUrl - 上传链接
187
204
  * @params {string} env - 环境
188
205
  * @params {string} description - 版本描述
206
+ * @params {string} did - 开发者 DID
189
207
  */
190
208
  export const uploadVersion = async (
191
209
  appId,
192
210
  downloadUrl,
193
211
  env = "prod",
194
212
  description = "",
213
+ did,
195
214
  ) => {
196
215
  try {
197
216
  const normalizedDescription = description.trim();
@@ -208,6 +227,7 @@ export const uploadVersion = async (
208
227
  ...(normalizedDescription
209
228
  ? { description: normalizedDescription }
210
229
  : {}),
230
+ ...(did ? { did } : {}),
211
231
  }),
212
232
  },
213
233
  env