You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.8 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
* <20>?V1.72 文档写入 demovip CC 配置<E9858D>?env 已对齐时使用)<E794A8>? * pnpm exec tsx scripts/apply-demovip-cc.ts
*/
import { getEnv, resetEnvCache } from "../src/lib/env";
import {
invalidateCcSettingsCache,
testCcLogin,
upsertCcSettings,
} from "../src/services/cc/settings-config";
import { getCcModeStatus } from "../src/services/cc/mode";
import { prisma } from "../src/services/db";
async function main() {
resetEnvCache();
const env = getEnv();
const pub = await upsertCcSettings({
mock: false,
apiBase: env.CC_API_BASE,
saasHeader: env.CC_SAAS_HEADER,
loginMark: env.CC_LOGIN_MARK,
username: (env.CC_USERNAME || "fj").trim(),
password: (env.CC_PASSWORD_PLAIN || "fj123qwe!").trim(),
});
// 文档有真链路的写能力<E883BD>?live;文档无接口的保<E79A84>?mock
const liveIds = ["save_container", "do_upload"] as const;
for (const id of liveIds) {
await prisma.ccWriteCapability.upsert({
where: { id },
create: {
id,
mode: "live",
endpoint:
id === "save_container"
? "/Container/SaveContainer"
: "/Container/SaveFieldValue",
},
update: { mode: "live" },
});
}
invalidateCcSettingsCache();
const status = await getCcModeStatus();
const login = await testCcLogin();
console.log(
JSON.stringify(
{
settings: pub,
mode: status,
login,
api_base: env.CC_API_BASE,
username: env.CC_USERNAME,
mock_env: env.CC_MOCK,
},
null,
2,
),
);
if (!login.ok) process.exit(2);
if (!status.live_ready) process.exit(1);
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});