@sap-ux/app-config-writer 0.6.10 → 0.6.11

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.
@@ -2,12 +2,20 @@ import type { Editor } from 'mem-fs-editor';
2
2
  import type { ToolsLogger } from '@sap-ux/logger';
3
3
  import type { PreviewConfigOptions } from '../types';
4
4
  import type { CustomMiddleware, FioriAppReloadConfig, UI5Config } from '@sap-ux/ui5-config';
5
- import { type DefaultFlpPath, type MiddlewareConfig as PreviewConfig, type TestConfig } from '@sap-ux/preview-middleware';
5
+ import { type DefaultFlpPath, type MiddlewareConfig as PreviewConfig, type TestConfig, type RtaConfig } from '@sap-ux/preview-middleware';
6
6
  import { type Script } from './package-json';
7
7
  type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType[number];
8
8
  type PreviewTestConfig = ArrayElement<Required<PreviewConfig>['test']>;
9
9
  export declare const DEFAULT_FLP_PATH: DefaultFlpPath;
10
10
  export declare const TEST_CONFIG_DEFAULTS: Record<string, Readonly<Required<PreviewTestConfig>>>;
11
+ /**
12
+ * Sanitize the deprecated RTA configuration.
13
+ *
14
+ * @param deprecatedRtaConfig deprecated RTA configuration
15
+ * @param logger logger instance
16
+ * @returns sanitized RTA configuration
17
+ */
18
+ export declare function sanitizeRtaConfig(deprecatedRtaConfig: PreviewConfig['rta'], logger?: ToolsLogger): RtaConfig | undefined;
11
19
  /**
12
20
  * Gets the reload middleware form the provided yamlConfig.
13
21
  * The middleware can either be named 'fiori-tools-appreload' or 'reload-middleware'.
@@ -44,9 +52,10 @@ export declare function updateMiddlewaresForPreview(fs: Editor, basePath: string
44
52
  * - no longer used property 'component' will be removed.
45
53
  *
46
54
  * @param previewMiddleware - the preview middleware
55
+ * @param logger - logger to report info to the user
47
56
  * @returns the sanitized preview middleware
48
57
  */
49
- export declare function sanitizePreviewMiddleware(previewMiddleware: CustomMiddleware<PreviewConfigOptions>): CustomMiddleware<PreviewConfig | undefined>;
58
+ export declare function sanitizePreviewMiddleware(previewMiddleware: CustomMiddleware<PreviewConfigOptions>, logger?: ToolsLogger): CustomMiddleware<PreviewConfig | undefined>;
50
59
  /**
51
60
  * Creates a preview middleware configuration.
52
61
  *
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TEST_CONFIG_DEFAULTS = exports.DEFAULT_FLP_PATH = void 0;
4
+ exports.sanitizeRtaConfig = sanitizeRtaConfig;
4
5
  exports.getEnhancedReloadMiddleware = getEnhancedReloadMiddleware;
5
6
  exports.createPreviewMiddlewareConfig = createPreviewMiddlewareConfig;
6
7
  exports.updateMiddlewaresForPreview = updateMiddlewaresForPreview;
@@ -12,7 +13,6 @@ const path_1 = require("path");
12
13
  const types_1 = require("../types");
13
14
  const project_access_1 = require("@sap-ux/project-access");
14
15
  const utils_1 = require("./utils");
15
- const preview_middleware_1 = require("@sap-ux/preview-middleware");
16
16
  const package_json_1 = require("./package-json");
17
17
  const DEFAULT_INTENT = {
18
18
  object: 'app',
@@ -33,6 +33,23 @@ exports.TEST_CONFIG_DEFAULTS = {
33
33
  framework: 'Testsuite'
34
34
  }
35
35
  };
36
+ /**
37
+ * Sanitize the deprecated RTA configuration.
38
+ *
39
+ * @param deprecatedRtaConfig deprecated RTA configuration
40
+ * @param logger logger instance
41
+ * @returns sanitized RTA configuration
42
+ */
43
+ //prettier-ignore
44
+ function sanitizeRtaConfig(deprecatedRtaConfig, logger) {
45
+ let rtaConfig;
46
+ if (deprecatedRtaConfig) {
47
+ const { editors, ...rta } = deprecatedRtaConfig;
48
+ rtaConfig = { ...rta, endpoints: [...editors] };
49
+ logger?.warn(`The configuration option 'rta' is deprecated and has been adjusted to 'editors.rta'.`);
50
+ }
51
+ return rtaConfig;
52
+ }
36
53
  /**
37
54
  * Gets the reload middleware form the provided yamlConfig.
38
55
  * The middleware can either be named 'fiori-tools-appreload' or 'reload-middleware'.
@@ -115,15 +132,16 @@ async function updateMiddlewaresForPreview(fs, basePath, yamlPath, logger) {
115
132
  * - no longer used property 'component' will be removed.
116
133
  *
117
134
  * @param previewMiddleware - the preview middleware
135
+ * @param logger - logger to report info to the user
118
136
  * @returns the sanitized preview middleware
119
137
  */
120
- function sanitizePreviewMiddleware(previewMiddleware) {
138
+ function sanitizePreviewMiddleware(previewMiddleware, logger) {
121
139
  if (!previewMiddleware.configuration) {
122
140
  return previewMiddleware;
123
141
  }
124
142
  //if we find the deprecated 'rta.editors' config, we will sanitize it
125
143
  if ('rta' in previewMiddleware.configuration) {
126
- const rtaConfig = (0, preview_middleware_1.sanitizeRtaConfig)(previewMiddleware.configuration.rta); //NOSONAR
144
+ const rtaConfig = sanitizeRtaConfig(previewMiddleware.configuration.rta, logger); //NOSONAR
127
145
  delete previewMiddleware.configuration.rta; //NOSONAR
128
146
  previewMiddleware.configuration.editors ??= {};
129
147
  previewMiddleware.configuration.editors.rta = rtaConfig;
@@ -157,7 +175,7 @@ function sanitizePreviewMiddleware(previewMiddleware) {
157
175
  async function updatePreviewMiddlewareConfig(previewMiddleware, script, basePath, fs, logger) {
158
176
  const { path, intent } = (0, package_json_1.extractUrlDetails)(script.value);
159
177
  const defaultIntent = `${DEFAULT_INTENT.object}-${DEFAULT_INTENT.action}`;
160
- const newMiddlewareConfig = sanitizePreviewMiddleware(previewMiddleware);
178
+ const newMiddlewareConfig = sanitizePreviewMiddleware(previewMiddleware, logger);
161
179
  //copy of configuration to avoid ending up with an empty configuration object in some cases
162
180
  const configuration = { ...newMiddlewareConfig.configuration };
163
181
  let writeConfig = false;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/app-config-writer",
3
3
  "description": "Add or update configuration for SAP Fiori tools application",
4
- "version": "0.6.10",
4
+ "version": "0.6.11",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -31,8 +31,8 @@
31
31
  "@sap-ux/btp-utils": "1.1.0",
32
32
  "@sap-ux/logger": "0.7.0",
33
33
  "@sap-ux/project-access": "1.30.2",
34
- "@sap-ux/store": "1.1.0",
35
- "@sap-ux/ui5-config": "0.28.2"
34
+ "@sap-ux/ui5-config": "0.28.2",
35
+ "@sap-ux/store": "1.1.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/ejs": "3.1.2",
@@ -42,7 +42,7 @@
42
42
  "@types/semver": "7.5.8",
43
43
  "axios": "1.8.2",
44
44
  "nock": "13.4.0",
45
- "@sap-ux/preview-middleware": "0.20.29"
45
+ "@sap-ux/preview-middleware": "0.20.37"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=20.x"