UNPKG

@lark-project/cli

Version:

飞书项目插件开发工具

68 lines (67 loc) 3.96 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.addLocalConfigCommand = void 0; // ⚠️ 改命令名 / flag / alias 时,同步 grep `lpm` skills/ .claude/skills/ 修文档引用 const path_1 = __importDefault(require("path")); const types_1 = require("../../types"); const run_script_1 = __importDefault(require("../../utils/run-script")); function addLocalConfigCommand(program) { const localConfig = program .command('local-config') .description('Manage local point configuration (file-based; reads/writes .lpm-cache/config/)'); localConfig .command('get') .description('Fetch remote point configuration and write it to .lpm-cache/config/remote.json. Prints the written path on stdout.') .option('--remote', 'Force fetch remote config (ignore local file)', false) .option('--compare-snapshot', 'Compare remote data with saved eval snapshot (requires --case-id)') .option('--case-id <case-id>', 'Eval case ID whose snapshot will be compared') .action(options => { const { remote, compareSnapshot, caseId } = options; (0, run_script_1.default)(path_1.default.join(__dirname, '../dispatcher'), [ '--command', types_1.ECommandName.localConfig, '--payload', JSON.stringify({ action: 'get', remote: Boolean(remote) || Boolean(compareSnapshot), compare_snapshot: Boolean(compareSnapshot), case_id: caseId, }), ]); }); localConfig .command('diff') .description('Preview pending changes: compare local point.config.local.json against remote. Prints ADDED/MODIFIED/DELETED lines on stdout. Exit 0 if no deletions, exit 2 with DELETION_REQUIRES_CONFIRMATION notice on stderr if deletions are detected. Use before "lpm update --source-type=local" to catch accidental deletions.') .action(() => { (0, run_script_1.default)(path_1.default.join(__dirname, '../dispatcher'), [ '--command', types_1.ECommandName.localConfig, '--payload', JSON.stringify({ action: 'diff', }), ]); }); localConfig .command('set') .description('Validate a draft point configuration JSON file and write it into the LOCAL point.config.local.json — this does NOT push to remote. To publish the config to the platform you MUST run "lpm update --source-type=local" afterwards. Typical flow: "lpm schema" → jq-slice → write draft to .lpm-cache/config/draft-<ts>.json → "lpm local-config set --from <that path>" → "lpm update --source-type=local". set is full-replacement and is built on top of the remote baseline: if the draft drops points that still exist on remote it exits 2 (build on `get --remote` first, or pass --allow-delete to confirm deletion). On success the draft and remote.json baseline are deleted automatically.') .requiredOption('--from <path>', 'Path to the draft JSON file (typically under .lpm-cache/config/)') .option('--allow-delete', 'Confirm deletion of remote points the draft omits (skips the baseline deletion gate)', false) .action(options => { const { from, allowDelete } = options; (0, run_script_1.default)(path_1.default.join(__dirname, '../dispatcher'), [ '--command', types_1.ECommandName.localConfig, '--payload', JSON.stringify({ action: 'set', fromPath: path_1.default.isAbsolute(from) ? from : path_1.default.resolve(process.cwd(), from), allow_delete: Boolean(allowDelete), }), ]); }); } exports.addLocalConfigCommand = addLocalConfigCommand;