UNPKG

@wishcbg/bobcode

Version:

基於店家同步功能的需求,讓店家能夠在不同的店家之間同步各項功能設定,並且能夠檢視各項功能的異動情況。 規劃出一套店家設定即程式碼的機制,讓店家能夠以 config file (.sac) 來定義各項功能設定,並且能夠還原店家各項功能設定。 暫且稱這個機制為「Settings as Code」「店家設定即程式碼」。

24 lines (23 loc) 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createPlanCommand = createPlanCommand; // src/commands/plan.ts const commander_1 = require("commander"); const file_js_1 = require("../utils/file.js"); const planHelper_js_1 = require("../utils/planHelper.js"); function createPlanCommand() { const cmd = new commander_1.Command('plan'); cmd .description('Compare origin & target config, generate change set') .requiredOption('--origin-config-file <path>', 'origin .sac.yaml 檔案路徑') .requiredOption('--target-config-file <path>', 'target .sac.yaml 檔案路徑') .requiredOption('--output <path>', '輸出 .cs.yaml 檔案路徑') .action(opts => { const origin = (0, file_js_1.readConfigFile)(opts.originConfigFile); const target = (0, file_js_1.readConfigFile)(opts.targetConfigFile); const cs = (0, planHelper_js_1.generateChangeSet)(origin, target); (0, file_js_1.writeChangeSet)(opts.output, cs); console.log(`總共 ${cs.changes.length} 個變更`); }); return cmd; }