UNPKG

@o3r/application

Version:

This module provides development help to monitor your Otter Application

31 lines 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.updateCmsJsonFile = updateCmsJsonFile; const node_path_1 = require("node:path"); /** * Update Otter cms.json in an Angular Project */ function updateCmsJsonFile() { return (tree, context) => { const filesToUpdate = {}; tree.visit((path) => { if ((0, node_path_1.basename)(path) === 'cms.json') { try { const contentObj = tree.readJson(path); if (typeof contentObj === 'object' && !contentObj.$schema) { filesToUpdate[path] = contentObj; } } catch { context.logger.warn(`Failed to parse '${path}'`); } } }); Object.entries(filesToUpdate).forEach(([path, contentObj]) => { contentObj.$schema = 'https://github.com/AmadeusITGroup/otter/blob/main/packages/@o3r/application/schemas/cms.schema.json'; tree.overwrite(path, JSON.stringify(contentObj, null, 2)); }); return tree; }; } //# sourceMappingURL=update-cms-config.js.map