UNPKG

@lark-project/cli

Version:

飞书项目插件开发工具

60 lines (59 loc) 2.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatMissingBaseInfoError = exports.collectMissingBaseInfo = void 0; /** * 计算「发布前缺哪些必填 base info」——纯函数,无网络,可单测。 * * 必填项:name / short / detail-description / icon;category 仅普通插件必填 * (AI 应用 app_type===1 跳过,对齐 ensurePluginMetadataReady 既有行为)。 * * detail-description 判空对齐 plainTextToRichText(update-plugin-description.ts): * 填过的富文本 is_empty===false 且 doc_text 为原文;从未填则 description 缺失或 is_empty===true。 * 这一项是本次新增——此前闸门只查 name/short/icon/category,detail 漏填能过闸门、却被后端 * commit 打回,导致版本建成半成品。 */ function collectMissingBaseInfo(descInfo) { var _a, _b, _c; const zh = (_a = descInfo.i18n_info) === null || _a === void 0 ? void 0 : _a['zh-cn']; const missing = []; if (!(zh === null || zh === void 0 ? void 0 : zh.name)) { missing.push({ field: 'name', hint: 'lpm update-description --name "<插件名>"' }); } if (!(zh === null || zh === void 0 ? void 0 : zh.short)) { missing.push({ field: 'short description', hint: 'lpm update-description --short-description "<≤100字短描述>"', }); } const detail = zh === null || zh === void 0 ? void 0 : zh.description; const hasDetail = !!detail && detail.is_empty !== true && !!((_b = detail.doc_text) === null || _b === void 0 ? void 0 : _b.trim()); if (!hasDetail) { missing.push({ field: 'detail description', hint: 'lpm update-description --detail-description "<详情,支持多段纯文本>"', }); } if (!descInfo.icon) { missing.push({ field: 'icon', hint: 'lpm update-description --icon "<图标URL>"' }); } // AI 应用(app_type===1)暂不支持分类,跳过 category;普通插件仍必填。 if (descInfo.app_type !== 1 && !((_c = descInfo.category_ids) === null || _c === void 0 ? void 0 : _c.length)) { missing.push({ field: 'category', hint: '先 `lpm list-categories` 取 id,再 `lpm update-description --category-ids <ids>`', }); } return missing; } exports.collectMissingBaseInfo = collectMissingBaseInfo; /** * 把缺失清单格式化成带逐字段可操作指引的错误信息(Layer 1 闸门 / Layer 2 commit 守卫共用)。 */ function formatMissingBaseInfoError(missing) { const lines = missing.map(m => ` • ${m.field}: ${m.hint}`); return [ 'Plugin metadata incomplete — the following base info is required before publishing:', ...lines, ].join('\n'); } exports.formatMissingBaseInfoError = formatMissingBaseInfoError;