@lark-project/cli
Version:
飞书项目插件开发工具
59 lines (58 loc) • 3.17 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.addCreateCommand = void 0;
// ⚠️ 改命令名 / flag / alias 时,同步 grep `lpm` skills/ .claude/skills/ 修文档引用
const path_1 = __importDefault(require("path"));
const types_1 = require("../../types");
const logger_1 = require("../../utils/logger");
const run_script_1 = __importDefault(require("../../utils/run-script"));
const validate_tools_1 = require("../../utils/validate-tools");
function addCreateCommand(program) {
program
.command('create')
.description('Create a new plugin and initialize the local project.')
.requiredOption('--site-domain <site-domain>', 'Specify the origin of the developer site, e.g. https://[example].com .')
.requiredOption('--name <name>', 'Specify the plugin name.')
.option('--description <description>', 'Specify the plugin short description.')
.option('--detail-description <detail-description>', 'Specify the plugin detail description.')
.option('--app-type <app-type>', `Plugin shape, one of: ${types_1.APP_TYPES.join(' | ')}. Locked at creation; cannot convert later.`, 'normal')
.option('-f, --force', 'Skip confirmation when current directory is already a plugin project.')
.action(async (options) => {
var _a, _b, _c, _d, _e;
const siteDomain = (_a = options.siteDomain) === null || _a === void 0 ? void 0 : _a.trim();
const name = (_b = options.name) === null || _b === void 0 ? void 0 : _b.trim();
const description = (_c = options.description) === null || _c === void 0 ? void 0 : _c.trim();
const detailDescription = (_d = options.detailDescription) === null || _d === void 0 ? void 0 : _d.trim();
const appType = (_e = options.appType) === null || _e === void 0 ? void 0 : _e.trim();
const force = options.force || false;
if (!(0, validate_tools_1.isValidURL)(siteDomain) || !siteDomain.startsWith('http')) {
logger_1.logger.error(`The siteDomain "${siteDomain}" is not valid (expected an absolute URL like https://project.feishu.cn (the developer-site origin)).`);
process.exit(1);
}
if (!name) {
logger_1.logger.error('The name is required, please check and retry.');
process.exit(1);
}
if (!appType || !types_1.APP_TYPES.includes(appType)) {
logger_1.logger.error(`The --app-type "${appType}" is not valid, expected one of: ${types_1.APP_TYPES.join(', ')}.`);
process.exit(1);
}
(0, run_script_1.default)(path_1.default.join(__dirname, '../dispatcher'), [
'--command',
types_1.ECommandName.create,
'--payload',
JSON.stringify({
siteDomain,
name,
description,
detailDescription,
appType,
force,
}),
]);
});
}
exports.addCreateCommand = addCreateCommand;