fix: 恢复小程序上传配置并固定产物目录

This commit is contained in:
que01 committed 2026-10-13 19:56:45 +08:00
1 parent ad949ab370
commit 26f1157083
5 files changed
+137 -21

No files matched your search

@@ -23,6 +23,8 @@ import {
UploadMiniAppReleaseDto,
} from "./admin-miniapp-release.dto.js";
const MINIAPP_ARTIFACT_ROOT = process.env.MINIAPP_ARTIFACT_ROOT ?? "apps/taro/dist";
interface MiniprogramCi {
Project: new (options: {
projectPath: string;
@@ -67,7 +69,7 @@ export class AdminMiniAppReleaseController {
const settings = this.jsonObject(brand?.miniAppSettings);
return {
appId: "",
artifactPath: "",
artifactPath: MINIAPP_ARTIFACT_ROOT,
build: {},
...settings,
privateKey: undefined,
@@ -97,12 +99,12 @@ export class AdminMiniAppReleaseController {
const settings = {
...current,
appId: body.appId ?? current.appId ?? "",
artifactPath: body.artifactPath ?? current.artifactPath ?? "",
build: {
...this.jsonObject(current.build),
...this.jsonObject(body.build),
} as Prisma.InputJsonObject,
...(credential ? { credential } : {}),
templateKey: current.templateKey ?? process.env.MINIAPP_TEMPLATE_KEY ?? "food",
} satisfies Prisma.InputJsonObject;
await this.prisma.brandProfile.update({
where: { id: identity.brandId },
@@ -110,8 +112,9 @@ export class AdminMiniAppReleaseController {
});
return {
appId: settings.appId,
artifactPath: settings.artifactPath,
artifactPath: MINIAPP_ARTIFACT_ROOT,
build: settings.build,
credential: settings.credential ? { algorithm: "aes-256-gcm" } : null,
hasStoredCredentials: Boolean(settings.credential),
};
}
@@ -153,11 +156,11 @@ export class AdminMiniAppReleaseController {
const privateKey = settings.credential
? decryptMiniAppCredential(settings.credential)
: this.requiredEnv("WECHAT_UPLOAD_PRIVATE_KEY");
const artifactPath =
typeof settings.artifactPath === "string" && settings.artifactPath
? settings.artifactPath
: this.requiredEnv("WEAPP_ARTIFACT_PATH");
const projectPath = resolve(artifactPath);
const templateKey =
typeof settings.templateKey === "string" && settings.templateKey
? settings.templateKey
: this.requiredEnv("MINIAPP_TEMPLATE_KEY");
const projectPath = resolve(MINIAPP_ARTIFACT_ROOT, templateKey, "weapp");
if (!existsSync(projectPath) || !existsSync(resolve(projectPath, "app.json")))
throw new BadRequestException("小程序构建产物不存在");
const ci = (await import("miniprogram-ci")) as unknown as MiniprogramCi;
@@ -7,14 +7,10 @@ export class UpdateMiniAppSettingsDto {
appId?: string;
@IsOptional()
@IsString()
artifactPath?: string;
@IsOptional()
@IsObject()
build?: Record<string, unknown>;
@IsOptional()
@IsString()
privateKey?: string;
}