@sap-ux/fe-fpm-writer 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -67,7 +67,7 @@ exports.enhanceManifestAndGetActionsElementReference = enhanceManifestAndGetActi
67
67
  * @returns {Promise<Editor>} the updated memfs editor instance
68
68
  */
69
69
  function generateCustomAction(basePath, actionConfig, fs) {
70
- validate_1.validateVersion(actionConfig.ui5Version);
70
+ validate_1.validateVersion(actionConfig.minUI5Version);
71
71
  if (!fs) {
72
72
  fs = mem_fs_editor_1.create(mem_fs_1.create());
73
73
  }
@@ -6,7 +6,7 @@ import type { CustomTableColumn } from './types';
6
6
  * @param ui5Version required UI5 version.
7
7
  * @returns path to the template folder containing the manifest.json ejs template
8
8
  */
9
- export declare function getManifestRoot(ui5Version?: number): string;
9
+ export declare function getManifestRoot(ui5Version?: string): string;
10
10
  /**
11
11
  * Add a custom column to an existing UI5 application.
12
12
  *
@@ -9,6 +9,7 @@ const defaults_1 = require("../common/defaults");
9
9
  const validate_1 = require("../common/validate");
10
10
  const event_handler_1 = require("../common/event-handler");
11
11
  const templates_1 = require("../templates");
12
+ const semver_1 = require("semver");
12
13
  /**
13
14
  * Get the template folder for the given UI5 version.
14
15
  *
@@ -16,10 +17,11 @@ const templates_1 = require("../templates");
16
17
  * @returns path to the template folder containing the manifest.json ejs template
17
18
  */
18
19
  function getManifestRoot(ui5Version) {
19
- if (ui5Version === undefined || ui5Version >= 1.86) {
20
+ const minVersion = semver_1.coerce(ui5Version);
21
+ if (!minVersion || minVersion.minor >= 86) {
20
22
  return templates_1.getTemplatePath('/column/1.86');
21
23
  }
22
- else if (ui5Version === 1.85) {
24
+ else if (minVersion.minor >= 85) {
23
25
  return templates_1.getTemplatePath('/column/1.85');
24
26
  }
25
27
  else {
@@ -60,7 +62,7 @@ function enhanceConfig(fs, data, manifestPath, manifest) {
60
62
  * @param {Editor} [fs] - the mem-fs editor instance
61
63
  */
62
64
  function generateCustomColumn(basePath, customColumn, fs) {
63
- validate_1.validateVersion(customColumn.ui5Version);
65
+ validate_1.validateVersion(customColumn.minUI5Version);
64
66
  if (!fs) {
65
67
  fs = mem_fs_editor_1.create(mem_fs_1.create());
66
68
  }
@@ -70,7 +72,7 @@ function generateCustomColumn(basePath, customColumn, fs) {
70
72
  // merge with defaults
71
73
  const completeColumn = enhanceConfig(fs, customColumn, manifestPath, manifest);
72
74
  // enhance manifest with column definition
73
- const manifestRoot = getManifestRoot(customColumn.ui5Version);
75
+ const manifestRoot = getManifestRoot(customColumn.minUI5Version);
74
76
  const filledTemplate = ejs_1.render(fs.read(path_1.join(manifestRoot, `manifest.json`)), completeColumn, {});
75
77
  fs.extendJSON(manifestPath, JSON.parse(filledTemplate));
76
78
  // add fragment
@@ -20,7 +20,7 @@ export interface CustomElement {
20
20
  * If undefined then the latest version of the template is used.
21
21
  * If nothing can be generated for the given version then an exception is thrown.
22
22
  */
23
- ui5Version?: number;
23
+ minUI5Version?: string;
24
24
  /**
25
25
  * If set to true then all code snippets are generated in Typescript instead of Javascript.
26
26
  */
@@ -5,7 +5,7 @@ import type { Editor } from 'mem-fs-editor';
5
5
  * @param ui5Version - optional minimum required UI5 version
6
6
  * @returns true if the version is supported otherwise throws an error
7
7
  */
8
- export declare function validateVersion(ui5Version?: number): boolean;
8
+ export declare function validateVersion(ui5Version?: string): boolean;
9
9
  /**
10
10
  * Validates the provided base path.
11
11
  *
@@ -4,6 +4,7 @@ exports.getErrorMessage = exports.validateBasePath = exports.validateVersion = v
4
4
  const path_1 = require("path");
5
5
  const mem_fs_1 = require("mem-fs");
6
6
  const mem_fs_editor_1 = require("mem-fs-editor");
7
+ const semver_1 = require("semver");
7
8
  /**
8
9
  * Validate that the UI5 version requirement is valid.
9
10
  *
@@ -11,7 +12,8 @@ const mem_fs_editor_1 = require("mem-fs-editor");
11
12
  * @returns true if the version is supported otherwise throws an error
12
13
  */
13
14
  function validateVersion(ui5Version) {
14
- if (ui5Version && ui5Version < 1.84) {
15
+ const minVersion = semver_1.coerce(ui5Version);
16
+ if (minVersion && minVersion.minor < 84) {
15
17
  throw new Error('SAP Fiori elements for OData v4 is only supported starting with SAPUI5 1.84.');
16
18
  }
17
19
  return true;
@@ -15,7 +15,7 @@ export declare function enhanceData(data: CustomPage, manifestPath: string, fs:
15
15
  * @param ui5Version - optional minimum required UI5 version
16
16
  * @returns root folder containg the templates if the version is supported otherwise throws an error
17
17
  */
18
- export declare function getTemplateRoot(ui5Version?: number): string;
18
+ export declare function getTemplateRoot(ui5Version?: string): string;
19
19
  /**
20
20
  * Add a custom page to an existing UI5 application.
21
21
  *
@@ -9,6 +9,7 @@ const common_1 = require("./common");
9
9
  const defaults_1 = require("../common/defaults");
10
10
  const validate_1 = require("../common/validate");
11
11
  const templates_1 = require("../templates");
12
+ const semver_1 = require("semver");
12
13
  /**
13
14
  * Enhances the provided custom page configuration with default data.
14
15
  *
@@ -40,7 +41,8 @@ exports.enhanceData = enhanceData;
40
41
  * @returns root folder containg the templates if the version is supported otherwise throws an error
41
42
  */
42
43
  function getTemplateRoot(ui5Version) {
43
- if (ui5Version === undefined || ui5Version >= 1.94) {
44
+ const minVersion = semver_1.coerce(ui5Version);
45
+ if (!minVersion || minVersion.minor >= 94) {
44
46
  return templates_1.getTemplatePath('/page/custom/1.94');
45
47
  }
46
48
  else {
@@ -60,12 +62,12 @@ function generate(basePath, data, fs) {
60
62
  if (!fs) {
61
63
  fs = mem_fs_editor_1.create(mem_fs_1.create());
62
64
  }
63
- validate_1.validateVersion(data.ui5Version);
65
+ validate_1.validateVersion(data.minUI5Version);
64
66
  common_1.validatePageConfig(basePath, data, fs);
65
67
  const manifestPath = path_1.join(basePath, 'webapp/manifest.json');
66
68
  const config = enhanceData(data, manifestPath, fs);
67
69
  // merge content into existing files
68
- const root = getTemplateRoot(data.ui5Version);
70
+ const root = getTemplateRoot(data.minUI5Version);
69
71
  // enhance manifest.json
70
72
  fs.extendJSON(manifestPath, JSON.parse(ejs_1.render(fs.read(path_1.join(root, `manifest.json`)), config, {})), common_1.getManifestJsonExtensionHelper(config));
71
73
  // add extension content
@@ -6,7 +6,7 @@ import type { CustomSection } from './types';
6
6
  * @param ui5Version required UI5 version.
7
7
  * @returns path to the template folder containing the manifest.json ejs template
8
8
  */
9
- export declare function getManifestRoot(ui5Version?: number): string;
9
+ export declare function getManifestRoot(ui5Version?: string): string;
10
10
  /**
11
11
  * Add a custom section to an existing UI5 application.
12
12
  *
@@ -9,6 +9,7 @@ const validate_1 = require("../common/validate");
9
9
  const defaults_1 = require("../common/defaults");
10
10
  const event_handler_1 = require("../common/event-handler");
11
11
  const templates_1 = require("../templates");
12
+ const semver_1 = require("semver");
12
13
  /**
13
14
  * Get the template folder for the given UI5 version.
14
15
  *
@@ -16,12 +17,13 @@ const templates_1 = require("../templates");
16
17
  * @returns path to the template folder containing the manifest.json ejs template
17
18
  */
18
19
  function getManifestRoot(ui5Version) {
19
- let subFolder = '1.86';
20
- if (ui5Version !== undefined && ui5Version < 1.86) {
21
- // Old
22
- subFolder = '1.85';
20
+ const minVersion = semver_1.coerce(ui5Version);
21
+ if (!minVersion || minVersion.minor >= 86) {
22
+ return templates_1.getTemplatePath('/section/1.86');
23
+ }
24
+ else {
25
+ return templates_1.getTemplatePath('/section/1.85');
23
26
  }
24
- return templates_1.getTemplatePath(path_1.join('section', subFolder));
25
27
  }
26
28
  exports.getManifestRoot = getManifestRoot;
27
29
  /**
@@ -53,7 +55,7 @@ function enhanceConfig(fs, data, manifestPath, manifest) {
53
55
  * @returns {Promise<Editor>} the updated mem-fs editor instance
54
56
  */
55
57
  function generateCustomSection(basePath, customSection, fs) {
56
- validate_1.validateVersion(customSection.ui5Version);
58
+ validate_1.validateVersion(customSection.minUI5Version);
57
59
  if (!fs) {
58
60
  fs = mem_fs_editor_1.create(mem_fs_1.create());
59
61
  }
@@ -63,7 +65,7 @@ function generateCustomSection(basePath, customSection, fs) {
63
65
  // merge with defaults
64
66
  const completeSection = enhanceConfig(fs, customSection, manifestPath, manifest);
65
67
  // enhance manifest with section definition
66
- const manifestRoot = getManifestRoot(customSection.ui5Version);
68
+ const manifestRoot = getManifestRoot(customSection.minUI5Version);
67
69
  const filledTemplate = ejs_1.render(fs.read(path_1.join(manifestRoot, `manifest.json`)), completeSection, {});
68
70
  fs.extendJSON(manifestPath, JSON.parse(filledTemplate));
69
71
  // add fragment
@@ -50,7 +50,7 @@ function enhanceConfig(fs, data, manifestPath, manifest) {
50
50
  * @returns {Promise<Editor>} the updated mem-fs editor instance
51
51
  */
52
52
  function generateCustomView(basePath, customView, fs) {
53
- validate_1.validateVersion(customView.ui5Version);
53
+ validate_1.validateVersion(customView.minUI5Version);
54
54
  if (!fs) {
55
55
  fs = mem_fs_editor_1.create(mem_fs_1.create());
56
56
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/fe-fpm-writer",
3
3
  "description": "SAP Fiori elements flexible programming model writer",
4
- "version": "0.16.0",
4
+ "version": "0.17.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",