qdmp-cli 0.1.7 → 0.1.8-beta.0
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/.claude/settings.local.json +8 -0
- package/actions.js +23 -10
- package/package.json +2 -2
package/actions.js
CHANGED
|
@@ -23,8 +23,8 @@ function createProject(appName, template) {
|
|
|
23
23
|
console.log("\n" + chalk.dim("─".repeat(60)) + "\n");
|
|
24
24
|
info(
|
|
25
25
|
`${template.emoji} 已为 ${chalk.bold(
|
|
26
|
-
appName
|
|
27
|
-
)} 选择模版:${chalk.underline(template.name)}
|
|
26
|
+
appName,
|
|
27
|
+
)} 选择模版:${chalk.underline(template.name)}`,
|
|
28
28
|
);
|
|
29
29
|
info(` ${chalk.dim("描述:")} ${template.desc}`);
|
|
30
30
|
info(` ${chalk.dim("仓库:")} ${chalk.green(template.value)}`);
|
|
@@ -134,7 +134,7 @@ export async function uploadAction(option) {
|
|
|
134
134
|
success(
|
|
135
135
|
`上传成功,版本号:${code},可前往官网进行小程序发布:https://${
|
|
136
136
|
option.env === "dev" ? "dev-" : ""
|
|
137
|
-
}
|
|
137
|
+
}open.qiandao.com/apps/${appId}/deploy`,
|
|
138
138
|
);
|
|
139
139
|
} catch (e) {
|
|
140
140
|
error(`${e.message}`);
|
|
@@ -144,7 +144,9 @@ export const initConfigAction = async (option) => {
|
|
|
144
144
|
try {
|
|
145
145
|
const qdmpJsonPath = `${process.cwd()}/qdmp.json`;
|
|
146
146
|
if (fs.existsSync(qdmpJsonPath)) {
|
|
147
|
-
return error(
|
|
147
|
+
return error(
|
|
148
|
+
"配置文件已存在,请勿重复初始化。或手动删除 qdmp.json 后重新初始化",
|
|
149
|
+
);
|
|
148
150
|
}
|
|
149
151
|
const appId = option.appId;
|
|
150
152
|
if (!appId) return error("未配置应用ID,请使用-a参数指定应用ID");
|
|
@@ -163,24 +165,35 @@ export const initConfigAction = async (option) => {
|
|
|
163
165
|
};
|
|
164
166
|
export const buildAction = async (option) => {
|
|
165
167
|
try {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
const qdmpJsonPath = `${process.cwd()}/qdmp.json`;
|
|
169
|
+
if (!fs.existsSync(qdmpJsonPath)) {
|
|
170
|
+
error("未找到 qdmp.json,请先执行 qdmp init 初始化项目");
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const config = JSON.parse(fs.readFileSync(qdmpJsonPath, "utf8"));
|
|
174
|
+
option = option ?? config;
|
|
175
|
+
switch (option.loader) {
|
|
176
|
+
case "EMP":
|
|
168
177
|
info("开始构建...");
|
|
169
|
-
const buildResult = shell.exec("
|
|
178
|
+
const buildResult = shell.exec("npm run build");
|
|
170
179
|
if (buildResult.code !== 0) {
|
|
171
180
|
throw new Error("构建失败");
|
|
172
181
|
}
|
|
173
182
|
shell.cd("dist");
|
|
174
|
-
const dmccResult = shell.exec("dmcc build --no-app-id-dir");
|
|
183
|
+
const dmccResult = shell.exec("npx dmcc build --no-app-id-dir");
|
|
175
184
|
if (dmccResult.code !== 0) {
|
|
176
|
-
throw new Error(
|
|
185
|
+
throw new Error(
|
|
186
|
+
"dmcc 构建失败,请保证 npm run build 产物是一个标准的微信小程序",
|
|
187
|
+
);
|
|
177
188
|
}
|
|
178
189
|
shell.cd("..");
|
|
179
190
|
success("构建完成");
|
|
180
191
|
break;
|
|
181
192
|
|
|
182
193
|
default:
|
|
183
|
-
error(
|
|
194
|
+
error(
|
|
195
|
+
`不支持的构建类型:${option.loader} 如果是空请检查qdmp.json配置文件是否正确`,
|
|
196
|
+
);
|
|
184
197
|
break;
|
|
185
198
|
}
|
|
186
199
|
} catch (e) {
|