Files
Genarrative/scripts/check-api-server-env.mjs
T
kdletters 29e84a77d1
Project CI / AI game creator shell Rust shard 2/4 (push) Successful in 5m31s
Project CI / AI game creator shell Rust shard 4/4 (push) Successful in 5m31s
Project CI / AI game creator shell Rust shard 1/4 (push) Successful in 5m47s
Project CI / AI game creator shell Rust shard 3/4 (push) Successful in 5m48s
Project CI / AI game creator shell Rust smoke (push) Successful in 1m43s
Project CI / AI game creator shell Rust crates (push) Successful in 2m3s
Project CI / Repository checks (push) Successful in 3m43s
Project CI / Frontend tests (push) Successful in 4m53s
Project CI / Native shell tests (push) Successful in 6m35s
Project CI / Backend tests (push) Successful in 7m25s
Project CI / AI game creator shell web tests (push) Successful in 2m35s
切换 Tiantoken 并删除旧 Vidu 音效
新增 TIANTOKEN_BASE_URL / TIANTOKEN_API_KEY 配置并切换文本与图片链路

保留 Suno VectorEngine 路径,删除旧 Vidu submit/poll/builder 实现

同步脚本、文档、测试与运行时 provider 路由
2026-09-15 19:43:35 +08:00

83 lines
2.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { mergeApiServerEnv } from './dev-utils.mjs';
const REQUIRED_FOR_PUZZLE_GENERATION = [
'TIANTOKEN_BASE_URL',
'TIANTOKEN_API_KEY',
'ALIYUN_OSS_BUCKET',
'ALIYUN_OSS_ENDPOINT',
'ALIYUN_OSS_ACCESS_KEY_ID',
'ALIYUN_OSS_ACCESS_KEY_SECRET',
];
const COMMON_MISTYPED_KEYS = [
'ALIYUN_0SS_BUCKET',
'ALIYUN_0SS_ENDPOINT',
'ALIYUN_0SS_ACCESS_KEY_ID',
'ALIYUN_0SS_ACCESS_KEY_SECRET',
];
function hasValue(value) {
return typeof value === 'string' && value.trim().length > 0;
}
function printStatus(key, present) {
console.log(`${key}: ${present ? 'present' : 'missing'}`);
}
const env = mergeApiServerEnv(process.cwd(), process.env);
const missing = [];
console.log('[api-server-env] 认证短信配置检查');
printStatus('SMS_AUTH_ENABLED', env.SMS_AUTH_ENABLED === 'true');
printStatus('SMS_AUTH_PROVIDER', hasValue(env.SMS_AUTH_PROVIDER));
console.log('[api-server-env] 编辑器真实生成配置检查');
for (const key of REQUIRED_FOR_PUZZLE_GENERATION) {
const present = hasValue(env[key]);
printStatus(key, present);
if (!present) {
missing.push(key);
}
}
const typoKeys = COMMON_MISTYPED_KEYS.filter((key) => hasValue(env[key]));
if (typoKeys.length > 0) {
console.log(
`[api-server-env] 检测到疑似拼错的 OSS 键名:${typoKeys.join(', ')}`,
);
}
// 阿里云通用抠图兜底层:默认 enabled=true,但 AccessKey 缺失时会被静默跳过,
// BgFilter 失败直接本地去背(质量下降)。属可选降级项,只告警不阻断部署。
console.log('[api-server-env] 抠图兜底(阿里云通用抠图)配置检查');
const mattingEnabled = env.GENARRATIVE_ALIYUN_MATTING_ENABLED !== 'false';
const mattingKeyPresent =
hasValue(env.GENARRATIVE_ALIYUN_MATTING_ACCESS_KEY_ID) ||
hasValue(env.ALIBABA_CLOUD_ACCESS_KEY_ID);
const mattingSecretPresent =
hasValue(env.GENARRATIVE_ALIYUN_MATTING_ACCESS_KEY_SECRET) ||
hasValue(env.ALIBABA_CLOUD_ACCESS_KEY_SECRET);
printStatus(
'GENARRATIVE_ALIYUN_MATTING_ACCESS_KEY_ID / ALIBABA_CLOUD_ACCESS_KEY_ID',
mattingKeyPresent,
);
printStatus(
'GENARRATIVE_ALIYUN_MATTING_ACCESS_KEY_SECRET / ALIBABA_CLOUD_ACCESS_KEY_SECRET',
mattingSecretPresent,
);
if (mattingEnabled && !(mattingKeyPresent && mattingSecretPresent)) {
console.warn(
'[api-server-env] 警告:GENARRATIVE_ALIYUN_MATTING_ENABLED 未关闭但缺少 AccessKey' +
'阿里云抠图兜底层将被跳过,BgFilter 失败后直接本地去背(质量下降)。',
);
}
if (missing.length > 0) {
console.error(`[api-server-env] 缺少:${missing.join(', ')}`);
process.exit(1);
}
console.log(
'[api-server-env] 配置齐全。重启 npm run dev:api-server 或 npm run dev 后生效。',
);