UNPKG

sfdx-experiences-plugin

Version:
26 lines 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const fs_1 = require("fs"); const fs_extra_1 = require("fs-extra"); /** * Copies the given source view file to the given target view file. Transforms app page IDs if given. * * @param {string} sourceFile Path to the source view file. * @param {string} targetFile Path to the target view file. * @param {Map<string, string>} [appPageIdMap] Optional mapping of app page IDs. */ function copyViewFile(sourceFile, targetFile, appPageIdMap) { if (!fs_1.existsSync(sourceFile)) { throw new Error(`Source view file does not exist: ${sourceFile}`); } const viewContent = fs_extra_1.readJsonSync(sourceFile); if (appPageIdMap) { if (!appPageIdMap.has(viewContent.appPageId)) { throw new Error(`Unable to map appPageId of source view file: ${sourceFile}`); } viewContent.appPageId = appPageIdMap.get(viewContent.appPageId); } fs_extra_1.writeJsonSync(targetFile, viewContent, { spaces: 2 }); } exports.default = copyViewFile; //# sourceMappingURL=copy-view-file.js.map