@sap-ux/adp-tooling 1.0.29 → 1.0.30

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.
@@ -7,9 +7,13 @@ import type { InternalInboundNavigation, DescriptorVariantContent } from '../typ
7
7
  * @param basePath - The base path of the project.
8
8
  * @param configs - The inbound configuration properties.
9
9
  * @param fs - Optional mem-fs editor instance.
10
+ * @param systemUI5Version - Optional UI5 version string from the system (e.g. '1.142.0').
11
+ * When the version is 1.142 or lower and the project is not a CF project, legacy change types are used.
12
+ * @param isCfProject - Whether this is a Cloud Foundry adaptation project. CF projects always use
13
+ * the new 'appdescr_app_setInbounds' change type regardless of UI5 version.
10
14
  * @returns The mem-fs editor instance.
11
15
  */
12
- export declare function generateInboundConfig(basePath: string, configs: InternalInboundNavigation[], fs?: Editor): Promise<Editor>;
16
+ export declare function generateInboundConfig(basePath: string, configs: InternalInboundNavigation[], fs?: Editor, systemUI5Version?: string, isCfProject?: boolean): Promise<Editor>;
13
17
  /**
14
18
  * Generates i18n entries for FLP configuration based on the provided configuration and application ID.
15
19
  *
@@ -3,16 +3,20 @@ import { create as createStorage } from 'mem-fs';
3
3
  import { create } from 'mem-fs-editor';
4
4
  import { SapShortTextType, removeAndCreateI18nEntries } from '@sap-ux/i18n';
5
5
  import { getVariant, updateVariant } from '../index.js';
6
- import { enhanceManifestChangeContentWithFlpConfig as enhanceInboundConfig } from './options.js';
6
+ import { enhanceManifestChangeContentWithFlpConfig as enhanceInboundConfig, shouldUseLegacyInboundChangeTypes } from './options.js';
7
7
  /**
8
8
  * Generates and writes the inbound configuration to the manifest.appdescr_variant file.
9
9
  *
10
10
  * @param basePath - The base path of the project.
11
11
  * @param configs - The inbound configuration properties.
12
12
  * @param fs - Optional mem-fs editor instance.
13
+ * @param systemUI5Version - Optional UI5 version string from the system (e.g. '1.142.0').
14
+ * When the version is 1.142 or lower and the project is not a CF project, legacy change types are used.
15
+ * @param isCfProject - Whether this is a Cloud Foundry adaptation project. CF projects always use
16
+ * the new 'appdescr_app_setInbounds' change type regardless of UI5 version.
13
17
  * @returns The mem-fs editor instance.
14
18
  */
15
- export async function generateInboundConfig(basePath, configs, fs) {
19
+ export async function generateInboundConfig(basePath, configs, fs, systemUI5Version, isCfProject = false) {
16
20
  if (!fs) {
17
21
  fs = create(createStorage());
18
22
  }
@@ -24,7 +28,8 @@ export async function generateInboundConfig(basePath, configs, fs) {
24
28
  config.inboundId = `${variant.id}.InboundID`;
25
29
  }
26
30
  }
27
- enhanceInboundConfig(configs, variant.id, variant.content);
31
+ const useLegacyChangeTypes = shouldUseLegacyInboundChangeTypes(systemUI5Version, isCfProject);
32
+ enhanceInboundConfig(configs, variant.id, variant.content, useLegacyChangeTypes);
28
33
  await updateVariant(basePath, variant, fs);
29
34
  await updateI18n(basePath, variant.id, configs, fs);
30
35
  return fs;
@@ -53,14 +53,28 @@ export declare function hasDeployConfig(config: AdpWriterConfig): config is AdpW
53
53
  * @param config full project configuration
54
54
  */
55
55
  export declare function enhanceUI5DeployYaml(ui5Config: UI5Config, config: AdpWriterConfigWithDeploy): void;
56
+ /**
57
+ * Determines whether the legacy inbound change types should be used based on the system UI5 version.
58
+ * Legacy change types ('appdescr_app_addNewInbound' + 'appdescr_app_removeAllInboundsExceptOne') are
59
+ * used for ABAP systems on UI5 1.142 or lower. CF projects always use the new type regardless of version.
60
+ * When the version cannot be determined on an ABAP system, legacy change types are used as a safe default
61
+ * since systems too old to expose a version service are almost certainly too old for 'appdescr_app_setInbounds'.
62
+ *
63
+ * @param systemUI5Version - The UI5 version string reported by the system (e.g. '1.142.0').
64
+ * @param isCfProject - Whether this is a Cloud Foundry adaptation project.
65
+ * @returns True when the legacy change types must be used.
66
+ */
67
+ export declare function shouldUseLegacyInboundChangeTypes(systemUI5Version: string | undefined, isCfProject: boolean): boolean;
56
68
  /**
57
69
  * Generate Inbound change content required for manifest.appdescriptor.
58
70
  *
59
71
  * @param flpConfigurations FLP cloud project configuration
60
72
  * @param appId Application variant id
61
73
  * @param manifestChangeContent Application variant change content
74
+ * @param useLegacyChangeTypes When true, use legacy 'appdescr_app_addNewInbound' +
75
+ * 'appdescr_app_removeAllInboundsExceptOne' change types instead of 'appdescr_app_setInbounds'.
62
76
  */
63
- export declare function enhanceManifestChangeContentWithFlpConfig(flpConfigurations: InternalInboundNavigation[], appId: string, manifestChangeContent?: Content[]): void;
77
+ export declare function enhanceManifestChangeContentWithFlpConfig(flpConfigurations: InternalInboundNavigation[], appId: string, manifestChangeContent?: Content[], useLegacyChangeTypes?: boolean): void;
64
78
  /**
65
79
  * Generate custom configuration required for the ui5.yaml.
66
80
  *
@@ -1,6 +1,13 @@
1
1
  import { UI5_CDN_URL } from '../base/constants/index.js';
2
2
  import { AdaptationProjectType } from '@sap-ux/axios-extension';
3
3
  import { SupportedProject } from '../source/index.js';
4
+ import { isFeatureSupportedVersion } from '../ui5/format.js';
5
+ /**
6
+ * ABAP added support for 'appdescr_app_setInbounds' in UI5 1.143. On older systems we must fall back
7
+ * to the legacy 'appdescr_app_addNewInbound' + 'appdescr_app_removeAllInboundsExceptOne' pair.
8
+ * CF projects always use the new type.
9
+ */
10
+ const MIN_VERSION_FOR_SET_INBOUNDS = '1.143.0';
4
11
  const VSCODE_URL = 'https://REQUIRED_FOR_VSCODE.example';
5
12
  /**
6
13
  * Generate the configuration for the middlewares required for the ui5.yaml.
@@ -261,24 +268,91 @@ function getInboundChangeContentWithNewInboundID(flpConfiguration, appId) {
261
268
  }
262
269
  return content;
263
270
  }
271
+ /**
272
+ * Determines whether the legacy inbound change types should be used based on the system UI5 version.
273
+ * Legacy change types ('appdescr_app_addNewInbound' + 'appdescr_app_removeAllInboundsExceptOne') are
274
+ * used for ABAP systems on UI5 1.142 or lower. CF projects always use the new type regardless of version.
275
+ * When the version cannot be determined on an ABAP system, legacy change types are used as a safe default
276
+ * since systems too old to expose a version service are almost certainly too old for 'appdescr_app_setInbounds'.
277
+ *
278
+ * @param systemUI5Version - The UI5 version string reported by the system (e.g. '1.142.0').
279
+ * @param isCfProject - Whether this is a Cloud Foundry adaptation project.
280
+ * @returns True when the legacy change types must be used.
281
+ */
282
+ export function shouldUseLegacyInboundChangeTypes(systemUI5Version, isCfProject) {
283
+ if (isCfProject) {
284
+ return false;
285
+ }
286
+ if (!systemUI5Version) {
287
+ return true;
288
+ }
289
+ return !isFeatureSupportedVersion(MIN_VERSION_FOR_SET_INBOUNDS, systemUI5Version);
290
+ }
291
+ /**
292
+ * Appends legacy inbound change entries ('appdescr_app_addNewInbound' +
293
+ * 'appdescr_app_removeAllInboundsExceptOne') for a single FLP configuration.
294
+ *
295
+ * @param flpConfig - The inbound configuration to write.
296
+ * @param appId - Application variant id.
297
+ * @param manifestChangeContent - Target array to push changes into.
298
+ * @param isFirst - Whether this is the first inbound in the list (controls removeAllInboundsExceptOne).
299
+ */
300
+ function appendLegacyInboundChanges(flpConfig, appId, manifestChangeContent, isFirst) {
301
+ const inboundChangeContent = getInboundChangeContentWithNewInboundID(flpConfig, appId);
302
+ manifestChangeContent.push({
303
+ changeType: 'appdescr_app_addNewInbound',
304
+ content: {
305
+ inbound: {
306
+ [flpConfig.inboundId]: inboundChangeContent.inbounds[flpConfig.inboundId]
307
+ }
308
+ },
309
+ texts: {
310
+ 'i18n': 'i18n/i18n.properties'
311
+ }
312
+ });
313
+ // Only emit 'removeAllInboundsExceptOne' after the first inbound is added.
314
+ // This change type wipes any inbounds inherited from the base app, keeping only
315
+ // the one just added. Subsequent inbounds in this loop are then stacked on top
316
+ // via additional 'appdescr_app_addNewInbound' entries. Emitting it later would
317
+ // race with the merge on the ABAP side.
318
+ if (isFirst) {
319
+ manifestChangeContent.push({
320
+ changeType: 'appdescr_app_removeAllInboundsExceptOne',
321
+ content: { inboundId: flpConfig.inboundId },
322
+ texts: {}
323
+ });
324
+ }
325
+ }
326
+ /**
327
+ * Appends a single 'appdescr_app_setInbounds' change entry for a single FLP configuration.
328
+ *
329
+ * @param flpConfig - The inbound configuration to write.
330
+ * @param appId - Application variant id.
331
+ * @param manifestChangeContent - Target array to push changes into.
332
+ */
333
+ function appendSetInboundsChange(flpConfig, appId, manifestChangeContent) {
334
+ const inboundChangeContent = getInboundChangeContentWithNewInboundID(flpConfig, appId);
335
+ manifestChangeContent.push({
336
+ changeType: 'appdescr_app_setInbounds',
337
+ content: inboundChangeContent,
338
+ texts: {
339
+ 'i18n': 'i18n/i18n.properties'
340
+ }
341
+ });
342
+ }
264
343
  /**
265
344
  * Generate Inbound change content required for manifest.appdescriptor.
266
345
  *
267
346
  * @param flpConfigurations FLP cloud project configuration
268
347
  * @param appId Application variant id
269
348
  * @param manifestChangeContent Application variant change content
349
+ * @param useLegacyChangeTypes When true, use legacy 'appdescr_app_addNewInbound' +
350
+ * 'appdescr_app_removeAllInboundsExceptOne' change types instead of 'appdescr_app_setInbounds'.
270
351
  */
271
- export function enhanceManifestChangeContentWithFlpConfig(flpConfigurations, appId, manifestChangeContent = []) {
272
- flpConfigurations.forEach((flpConfig) => {
273
- const inboundChangeContent = getInboundChangeContentWithNewInboundID(flpConfig, appId);
274
- const addInboundChange = {
275
- changeType: 'appdescr_app_setInbounds',
276
- content: inboundChangeContent,
277
- texts: {
278
- 'i18n': 'i18n/i18n.properties'
279
- }
280
- };
281
- manifestChangeContent.push(addInboundChange);
352
+ export function enhanceManifestChangeContentWithFlpConfig(flpConfigurations, appId, manifestChangeContent = [], useLegacyChangeTypes = false) {
353
+ const append = useLegacyChangeTypes ? appendLegacyInboundChanges : appendSetInboundsChange;
354
+ flpConfigurations.forEach((flpConfig, index) => {
355
+ append(flpConfig, appId, manifestChangeContent, index === 0);
282
356
  });
283
357
  }
284
358
  /**
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "bugs": {
11
11
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aadp-tooling"
12
12
  },
13
- "version": "1.0.29",
13
+ "version": "1.0.30",
14
14
  "license": "Apache-2.0",
15
15
  "author": "@SAP/ux-tools-team",
16
16
  "main": "dist/index.js",