"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const json_merge_patch_1 = __importDefault(require("json-merge-patch"));
const fs_1 = __importDefault(require("fs"));
if (!fs_1.default.existsSync("./api/sfcc-api.json")) {
    console.log('Make api patches - get original definition using scrape first');
}
else if (!fs_1.default.existsSync("./api/sfcc-api-patched.json")) {
    const patched = json_merge_patch_1.default.apply(JSON.parse(fs_1.default.readFileSync("./api/sfcc-api.json", "utf8")), JSON.parse(fs_1.default.readFileSync("./api/patches.json", "utf8")));
    fs_1.default.writeFileSync('./api/sfcc-api-patched.json', JSON.stringify(patched, null, 2));
    console.log('Make api patches - apply your modifications to api/sfcc-api-patched.json and run again to generate a patch file');
}
else {
    console.log('Make api patches - generating patches file to api/patches.json');
    var patches = json_merge_patch_1.default.generate(JSON.parse(fs_1.default.readFileSync("./api/sfcc-api.json", "utf8")), JSON.parse(fs_1.default.readFileSync("./api/sfcc-api-patched.json", "utf8")));
    fs_1.default.writeFileSync('./api/patches.json', JSON.stringify(patches, null, 2));
}
