@lark-project/cli
Version:
飞书项目插件开发工具
39 lines (38 loc) • 2.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ensurePluginMetadataReady = void 0;
const update_plugin_description_1 = require("../../../api/tools/update-plugin-description");
const logger_1 = require("../../../utils/logger");
const app_type_guard_1 = require("../publish/app-type-guard");
const collect_missing_base_info_1 = require("./collect-missing-base-info");
/**
* 发布前置闸门(PC0):拉后端插件元信息,校验 name / short / detail-description / icon /
* category 完整(缺失项判定与逐字段指引见 collectMissingBaseInfo),并顺带用后端真实
* app_type / point_types 对账本地 app_type。
*
* 仅供 `publishProject` 调用:publish 链路本就要求登录态,元信息闸门走 description/info
* (经 getToolAuthHeaders / Bearer)放在这里才合理。
*
* ⚠️ 不要再把它加进 `releaseProject`:release 是零登录态命令(只做本地 build + zip +
* uploadZipFile,靠 X-MEEGO-TOKEN 插件 secret 鉴权),调它会请求需要登录态的 description/info,
* 破坏 release 的零鉴权不变量。曾在 commit fa088ef 为 fail-fast 加进 release,已回退。
*
* 元信息缺失或 app_type 不符时抛错(由调用方 catch → process.exit(1))。
*
* 校验通过后返回拉到的 descInfo(草稿态元信息),供调用方复用——publishAIPlugin 用它
* 打印「即将随全量发布上线的 base info」,无需二次拉取。
*/
async function ensurePluginMetadataReady({ siteDomain, appKey, localAppType, }) {
logger_1.logger.info('Checking plugin metadata...');
const descInfo = await (0, update_plugin_description_1.getPluginDescriptionInfo)({ siteDomain, appKey });
// 串链路强校验:descInfo 自带后端真实 app_type / point_types,先比对再查元信息完整性——
// 形态不符时直接抛错,比"缺 name/icon"这类下游报错更贴近根因。
(0, app_type_guard_1.assertAppTypeMatchesBackend)(localAppType, descInfo);
const missing = (0, collect_missing_base_info_1.collectMissingBaseInfo)(descInfo);
if (missing.length > 0) {
throw new Error((0, collect_missing_base_info_1.formatMissingBaseInfoError)(missing));
}
logger_1.logger.success('Plugin metadata check passed.');
return descInfo;
}
exports.ensurePluginMetadataReady = ensurePluginMetadataReady;