@sap-ux/fe-fpm-writer
Advanced tools
Comparing version 0.18.3 to 0.18.4
@@ -13,2 +13,3 @@ "use strict"; | ||
const templates_1 = require("../templates"); | ||
const file_1 = require("../common/file"); | ||
/** | ||
@@ -86,3 +87,3 @@ * Enhances the provided custom action configuration with default data. | ||
Object.assign(actions, JSON.parse(ejs_1.render(fs.read(templates_1.getTemplatePath(`action/manifest.action.json`)), config, {}))); | ||
fs.writeJSON(manifestPath, manifest); | ||
fs.writeJSON(manifestPath, manifest, undefined, file_1.getJsonSpace(fs, manifestPath, actionConfig.tabInfo)); | ||
return fs; | ||
@@ -89,0 +90,0 @@ } |
@@ -11,2 +11,3 @@ "use strict"; | ||
const event_handler_1 = require("../common/event-handler"); | ||
const file_1 = require("../common/file"); | ||
const templates_1 = require("../templates"); | ||
@@ -78,3 +79,7 @@ const semver_1 = require("semver"); | ||
const filledTemplate = ejs_1.render(fs.read(path_1.join(manifestRoot, `manifest.json`)), completeColumn, {}); | ||
fs.extendJSON(manifestPath, JSON.parse(filledTemplate)); | ||
file_1.extendJSON(fs, { | ||
filepath: manifestPath, | ||
content: filledTemplate, | ||
tabInfo: customColumn.tabInfo | ||
}); | ||
// add fragment | ||
@@ -81,0 +86,0 @@ const viewPath = path_1.join(completeColumn.path, `${completeColumn.name}.fragment.xml`); |
@@ -5,6 +5,10 @@ import type { ManifestNamespace } from '@sap-ux/project-access'; | ||
}; | ||
export interface TabInfo { | ||
size?: number; | ||
useTabSymbol?: boolean; | ||
} | ||
/** | ||
* Common properties for any custom element of the flexible programming model. | ||
*/ | ||
export interface CustomElement { | ||
export interface CustomElement extends WriterConfig { | ||
/** | ||
@@ -153,2 +157,9 @@ * Name of the custom element that is to be added to the application. | ||
} | ||
export interface WriterConfig { | ||
/** | ||
* Tab size info. | ||
* Currently is used only for 'manifest.json' update. | ||
*/ | ||
tabInfo?: TabInfo; | ||
} | ||
//# sourceMappingURL=types.d.ts.map |
@@ -13,2 +13,3 @@ "use strict"; | ||
const utils_1 = require("../common/utils"); | ||
const file_1 = require("../common/file"); | ||
exports.UI5_CONTROLLER_EXTENSION_LIST_REPORT = 'sap.fe.templates.ListReport.ListReportController'; | ||
@@ -187,3 +188,8 @@ exports.UI5_CONTROLLER_EXTENSION_OBJECT_PAGE = 'sap.fe.templates.ObjectPage.ObjectPageController'; | ||
const filledTemplate = ejs_1.render(fs.read(templates_1.getTemplatePath('controller-extension/manifest.json')), internalConfig, {}); | ||
fs.extendJSON(manifestPath, JSON.parse(filledTemplate), getManifestReplacer(internalConfig)); | ||
file_1.extendJSON(fs, { | ||
filepath: manifestPath, | ||
content: filledTemplate, | ||
replacer: getManifestReplacer(internalConfig), | ||
tabInfo: controllerConfig.tabInfo | ||
}); | ||
// add controller js file | ||
@@ -190,0 +196,0 @@ const ext = controllerConfig.typescript ? 'ts' : 'js'; |
import type { Editor } from 'mem-fs-editor'; | ||
import type { ManifestNamespace } from '@sap-ux/project-access'; | ||
import type { CustomPage, FCL, InternalCustomPage, InternalObjectPage, ObjectPage, Navigation, InternalListReport } from './types'; | ||
import type { CustomPage, FCL, InternalCustomPage, InternalObjectPage, ObjectPage, ListReport, Navigation, InternalListReport } from './types'; | ||
import type { Manifest } from '../common/types'; | ||
declare type EnhancePageConfigFunction = (data: ObjectPage | ListReport, manifest: Manifest) => InternalObjectPage | InternalListReport; | ||
/** | ||
@@ -52,2 +53,15 @@ * Suffix for patterns to support arbitrary paramters | ||
export declare function validatePageConfig(basePath: string, config: CustomPage | ObjectPage, fs: Editor): Editor; | ||
/** | ||
* Add an generic page to an existing UI5 application. | ||
* Supported pages - ListReport or ObjectPage. | ||
* | ||
* @param basePath - the base path | ||
* @param data - the page configuration | ||
* @param enhanceDataFn - Callback function for data enhancement | ||
* @param templatePath - path to 'manifest.json' template | ||
* @param fs - the memfs editor instance | ||
* @returns the updated memfs editor instance | ||
*/ | ||
export declare function extendPageJSON(basePath: string, data: ObjectPage, enhanceDataFn: EnhancePageConfigFunction, templatePath: string, fs?: Editor): Editor; | ||
export {}; | ||
//# sourceMappingURL=common.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validatePageConfig = exports.getFclConfig = exports.getManifestJsonExtensionHelper = exports.generateRouteTarget = exports.generateRoutePattern = exports.PATTERN_SUFFIX = void 0; | ||
exports.extendPageJSON = exports.validatePageConfig = exports.getFclConfig = exports.getManifestJsonExtensionHelper = exports.generateRouteTarget = exports.generateRoutePattern = exports.PATTERN_SUFFIX = void 0; | ||
const mem_fs_1 = require("mem-fs"); | ||
const mem_fs_editor_1 = require("mem-fs-editor"); | ||
const path_1 = require("path"); | ||
const ejs_1 = require("ejs"); | ||
const validate_1 = require("../common/validate"); | ||
const defaults_1 = require("../common/defaults"); | ||
const file_1 = require("../common/file"); | ||
const templates_1 = require("../templates"); | ||
/** | ||
@@ -157,2 +162,31 @@ * Suffix for patterns to support arbitrary paramters | ||
exports.validatePageConfig = validatePageConfig; | ||
/** | ||
* Add an generic page to an existing UI5 application. | ||
* Supported pages - ListReport or ObjectPage. | ||
* | ||
* @param basePath - the base path | ||
* @param data - the page configuration | ||
* @param enhanceDataFn - Callback function for data enhancement | ||
* @param templatePath - path to 'manifest.json' template | ||
* @param fs - the memfs editor instance | ||
* @returns the updated memfs editor instance | ||
*/ | ||
function extendPageJSON(basePath, data, enhanceDataFn, templatePath, fs) { | ||
if (!fs) { | ||
fs = mem_fs_editor_1.create(mem_fs_1.create()); | ||
} | ||
validatePageConfig(basePath, data, fs); | ||
const manifestPath = path_1.join(basePath, 'webapp/manifest.json'); | ||
const manifest = fs.readJSON(manifestPath); | ||
const config = enhanceDataFn(data, manifest); | ||
// enhance manifest.json | ||
file_1.extendJSON(fs, { | ||
filepath: manifestPath, | ||
content: ejs_1.render(fs.read(templates_1.getTemplatePath(templatePath)), config, {}), | ||
replacer: getManifestJsonExtensionHelper(config), | ||
tabInfo: data.tabInfo | ||
}); | ||
return fs; | ||
} | ||
exports.extendPageJSON = extendPageJSON; | ||
//# sourceMappingURL=common.js.map |
@@ -14,2 +14,3 @@ "use strict"; | ||
const utils_1 = require("../common/utils"); | ||
const file_1 = require("../common/file"); | ||
/** | ||
@@ -74,3 +75,8 @@ * Enhances the provided custom page configuration with default data. | ||
// enhance manifest.json | ||
fs.extendJSON(manifestPath, JSON.parse(ejs_1.render(fs.read(path_1.join(root, `manifest.json`)), config, {})), common_1.getManifestJsonExtensionHelper(config)); | ||
file_1.extendJSON(fs, { | ||
filepath: manifestPath, | ||
content: ejs_1.render(fs.read(path_1.join(root, `manifest.json`)), config, {}), | ||
replacer: common_1.getManifestJsonExtensionHelper(config), | ||
tabInfo: data.tabInfo | ||
}); | ||
// add extension content | ||
@@ -77,0 +83,0 @@ const viewPath = path_1.join(config.path, `${config.name}.view.xml`); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generate = void 0; | ||
const path_1 = require("path"); | ||
const mem_fs_1 = require("mem-fs"); | ||
const mem_fs_editor_1 = require("mem-fs-editor"); | ||
const ejs_1 = require("ejs"); | ||
const common_1 = require("./common"); | ||
const templates_1 = require("../templates"); | ||
/** | ||
@@ -47,14 +42,5 @@ * Enhances the provided list report configuration with default data. | ||
function generate(basePath, data, fs) { | ||
if (!fs) { | ||
fs = mem_fs_editor_1.create(mem_fs_1.create()); | ||
} | ||
common_1.validatePageConfig(basePath, data, fs); | ||
const manifestPath = path_1.join(basePath, 'webapp/manifest.json'); | ||
const manifest = fs.readJSON(manifestPath); | ||
const config = enhanceData(data, manifest); | ||
// enhance manifest.json | ||
fs.extendJSON(manifestPath, JSON.parse(ejs_1.render(fs.read(templates_1.getTemplatePath('page/list/manifest.json')), config, {})), common_1.getManifestJsonExtensionHelper(config)); | ||
return fs; | ||
return common_1.extendPageJSON(basePath, data, enhanceData, 'page/list/manifest.json', fs); | ||
} | ||
exports.generate = generate; | ||
//# sourceMappingURL=list.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generate = void 0; | ||
const path_1 = require("path"); | ||
const mem_fs_1 = require("mem-fs"); | ||
const mem_fs_editor_1 = require("mem-fs-editor"); | ||
const ejs_1 = require("ejs"); | ||
const common_1 = require("./common"); | ||
const templates_1 = require("../templates"); | ||
/** | ||
@@ -37,14 +32,5 @@ * Enhances the provided list report configuration with default data. | ||
function generate(basePath, data, fs) { | ||
if (!fs) { | ||
fs = mem_fs_editor_1.create(mem_fs_1.create()); | ||
} | ||
common_1.validatePageConfig(basePath, data, fs); | ||
const manifestPath = path_1.join(basePath, 'webapp/manifest.json'); | ||
const manifest = fs.readJSON(manifestPath); | ||
const config = enhanceData(data, manifest); | ||
// enhance manifest.json | ||
fs.extendJSON(manifestPath, JSON.parse(ejs_1.render(fs.read(templates_1.getTemplatePath('/page/object/manifest.json')), config, {})), common_1.getManifestJsonExtensionHelper(config)); | ||
return fs; | ||
return common_1.extendPageJSON(basePath, data, enhanceData, '/page/object/manifest.json', fs); | ||
} | ||
exports.generate = generate; | ||
//# sourceMappingURL=object.js.map |
@@ -1,2 +0,2 @@ | ||
import type { CustomElement, InternalCustomElement } from '../common/types'; | ||
import type { CustomElement, InternalCustomElement, WriterConfig } from '../common/types'; | ||
/** | ||
@@ -36,3 +36,3 @@ * Incoming navigation configuration. | ||
*/ | ||
export interface ListReport { | ||
export interface ListReport extends WriterConfig { | ||
/** | ||
@@ -50,3 +50,3 @@ * Name of the entity used for the custom page. | ||
*/ | ||
export interface ObjectPage { | ||
export interface ObjectPage extends WriterConfig { | ||
/** | ||
@@ -53,0 +53,0 @@ * Name of the entity used for the custom page. |
@@ -11,2 +11,3 @@ "use strict"; | ||
const event_handler_1 = require("../common/event-handler"); | ||
const file_1 = require("../common/file"); | ||
const templates_1 = require("../templates"); | ||
@@ -83,3 +84,7 @@ const semver_1 = require("semver"); | ||
const filledTemplate = ejs_1.render(fs.read(path_1.join(manifestRoot, `manifest.json`)), completeSection, {}); | ||
fs.extendJSON(manifestPath, JSON.parse(filledTemplate)); | ||
file_1.extendJSON(fs, { | ||
filepath: manifestPath, | ||
content: filledTemplate, | ||
tabInfo: customSection.tabInfo | ||
}); | ||
// add fragment | ||
@@ -86,0 +91,0 @@ const viewPath = path_1.join(completeSection.path, `${completeSection.name}.fragment.xml`); |
@@ -11,2 +11,3 @@ "use strict"; | ||
const event_handler_1 = require("../common/event-handler"); | ||
const file_1 = require("../common/file"); | ||
const templates_1 = require("../templates"); | ||
@@ -92,3 +93,7 @@ /** | ||
const filledTemplate = ejs_1.render(fs.read(templates_1.getTemplatePath('view/manifest.json')), completeView, {}); | ||
fs.extendJSON(manifestPath, JSON.parse(filledTemplate)); | ||
file_1.extendJSON(fs, { | ||
filepath: manifestPath, | ||
content: filledTemplate, | ||
tabInfo: customView.tabInfo | ||
}); | ||
// add fragment | ||
@@ -95,0 +100,0 @@ if (customView.viewUpdate !== false) { |
{ | ||
"name": "@sap-ux/fe-fpm-writer", | ||
"description": "SAP Fiori elements flexible programming model writer", | ||
"version": "0.18.3", | ||
"version": "0.18.4", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
160875
87
3512