@ui5/task-adaptation 1.6.5-rc.2 → 1.6.5-rc.4

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.
Files changed (82) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/REUSE.toml +1 -1
  3. package/dist/adapters/abapAdapter.d.ts +7 -5
  4. package/dist/adapters/abapAdapter.js +9 -11
  5. package/dist/adapters/adapter.d.ts +9 -5
  6. package/dist/adapters/adapter.js +20 -0
  7. package/dist/adapters/cfAdapter.d.ts +8 -5
  8. package/dist/adapters/cfAdapter.js +16 -10
  9. package/dist/adapters/commands/command.d.ts +26 -23
  10. package/dist/adapters/commands/command.js +73 -46
  11. package/dist/adapters/commands/fetchEndpointsCommand.d.ts +9 -0
  12. package/dist/adapters/commands/fetchEndpointsCommand.js +21 -0
  13. package/dist/adapters/commands/fetchPreviewResourcesCommand.d.ts +15 -0
  14. package/dist/adapters/commands/fetchPreviewResourcesCommand.js +103 -0
  15. package/dist/adapters/commands/filterFilesCommand.d.ts +4 -0
  16. package/dist/adapters/commands/filterFilesCommand.js +22 -0
  17. package/dist/adapters/commands/omitDeletedResourcesCommand.d.ts +10 -0
  18. package/dist/adapters/commands/omitDeletedResourcesCommand.js +31 -0
  19. package/dist/adapters/commands/processPreviewResourcesCommand.d.ts +9 -0
  20. package/dist/adapters/commands/processPreviewResourcesCommand.js +55 -0
  21. package/dist/adapters/commands/renameFilesCommand.d.ts +20 -0
  22. package/dist/{util/filesUtil.js → adapters/commands/renameFilesCommand.js} +34 -43
  23. package/dist/adapters/commands/writeResourcesCommand.d.ts +7 -0
  24. package/dist/adapters/commands/writeResourcesCommand.js +20 -0
  25. package/dist/adapters/commands/xsAppJsonEnhanceRoutesCommand.d.ts +3 -3
  26. package/dist/adapters/commands/xsAppJsonEnhanceRoutesCommand.js +4 -4
  27. package/dist/adapters/previewAdapter.d.ts +12 -6
  28. package/dist/adapters/previewAdapter.js +28 -7
  29. package/dist/annotations/abapAnnotationManager.js +1 -1
  30. package/dist/annotations/dataSource/dataSourceManager.d.ts +2 -1
  31. package/dist/annotations/dataSource/dataSourceManager.js +16 -7
  32. package/dist/{appVariantManager.d.ts → appVariant.d.ts} +2 -9
  33. package/dist/{appVariantManager.js → appVariant.js} +16 -28
  34. package/dist/{baseAppManager.js → baseApp.js} +6 -12
  35. package/dist/bundle.js +53 -12
  36. package/dist/cache/cacheHolder.d.ts +3 -3
  37. package/dist/cache/cacheHolder.js +8 -7
  38. package/dist/cache/cachedResource.d.ts +4 -0
  39. package/dist/cache/cachedResource.js +2 -0
  40. package/dist/index.d.ts +1 -1
  41. package/dist/index.js +44 -69
  42. package/dist/landscapeConfiguration.d.ts +2 -2
  43. package/dist/landscapeConfiguration.js +39 -37
  44. package/dist/model/configuration.d.ts +1 -4
  45. package/dist/model/configuration.js +1 -1
  46. package/dist/model/types.d.ts +9 -2
  47. package/dist/repositories/abapProvider.js +2 -2
  48. package/dist/repositories/abapRepository.d.ts +6 -5
  49. package/dist/repositories/abapRepository.js +10 -11
  50. package/dist/repositories/html5Repository.d.ts +8 -5
  51. package/dist/repositories/html5Repository.js +18 -30
  52. package/dist/repositories/localRepository.d.ts +8 -12
  53. package/dist/repositories/localRepository.js +53 -43
  54. package/dist/repositories/repository.d.ts +3 -5
  55. package/dist/util/cf/xsAppJsonUtil.d.ts +16 -3
  56. package/dist/util/cf/xsAppJsonUtil.js +7 -18
  57. package/dist/util/commonUtil.d.ts +6 -0
  58. package/dist/util/commonUtil.js +17 -0
  59. package/dist/util/fsUtil.d.ts +2 -3
  60. package/dist/util/fsUtil.js +12 -33
  61. package/dist/util/renamingUtil.js +50 -82
  62. package/dist/util/resourceUtil.d.ts +21 -5
  63. package/dist/util/resourceUtil.js +52 -11
  64. package/dist/util/validator/abapConnectionValidator.d.ts +5 -0
  65. package/dist/util/validator/abapConnectionValidator.js +22 -0
  66. package/dist/util/validator/abapValidator.d.ts +2 -4
  67. package/dist/util/validator/abapValidator.js +4 -16
  68. package/dist/util/validator/validator.d.ts +1 -0
  69. package/dist/util/validator/validator.js +11 -0
  70. package/dist/util/workspaceManager.d.ts +9 -0
  71. package/dist/util/workspaceManager.js +46 -0
  72. package/dist/util/zipUtil.d.ts +1 -1
  73. package/dist/util/zipUtil.js +1 -1
  74. package/package.json +13 -13
  75. package/.hyperspace/pull_request_bot.json +0 -19
  76. package/dist/previewManager.d.ts +0 -14
  77. package/dist/previewManager.js +0 -141
  78. package/dist/util/filesUtil.d.ts +0 -19
  79. package/scripts/metadataDownloadHelper.ts +0 -88
  80. package/scripts/publish.ts +0 -256
  81. package/scripts/test-integration-prep.sh +0 -4
  82. /package/dist/{baseAppManager.d.ts → baseApp.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -2,7 +2,16 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
4
4
 
5
- A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task-adaptation/compare/v1.6.5-rc.2...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task-adaptation/compare/v1.6.5-rc.4...HEAD).
6
+
7
+ <a name="v1.6.5-rc.4"></a>
8
+ ## [v1.6.5-rc.4] - 2026-06-23
9
+
10
+ <a name="v1.6.5-rc.3"></a>
11
+ ## [v1.6.5-rc.3] - 2026-04-27
12
+ ### Reverts
13
+ - Release 1.6.5-rc.0
14
+
6
15
 
7
16
  <a name="v1.6.5-rc.2"></a>
8
17
  ## [v1.6.5-rc.2] - 2026-04-14
@@ -188,6 +197,8 @@ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task
188
197
  <a name="v1.0.0"></a>
189
198
  ## v1.0.0 - 2020-12-09
190
199
 
200
+ [v1.6.5-rc.4]: https://github.com/SAP/ui5-task-adaptation/compare/v1.6.5-rc.3...v1.6.5-rc.4
201
+ [v1.6.5-rc.3]: https://github.com/SAP/ui5-task-adaptation/compare/v1.6.5-rc.2...v1.6.5-rc.3
191
202
  [v1.6.5-rc.2]: https://github.com/SAP/ui5-task-adaptation/compare/v1.6.5-rc.1...v1.6.5-rc.2
192
203
  [v1.6.5-rc.1]: https://github.com/SAP/ui5-task-adaptation/compare/v1.6.4-rc.3...v1.6.5-rc.1
193
204
  [v1.6.4-rc.3]: https://github.com/SAP/ui5-task-adaptation/compare/v1.6.4-rc.2...v1.6.4-rc.3
package/REUSE.toml CHANGED
@@ -7,4 +7,4 @@ SPDX-PackageDownloadLocation = "https://github.com/SAP/ui5-task-adaptation"
7
7
  path = "**.**"
8
8
  precedence = "aggregate"
9
9
  SPDX-FileCopyrightText = "2009-2025 SAP SE or an SAP affiliate company"
10
- SPDX-License-Identifier = "Apache-2.0"
10
+ SPDX-License-Identifier = "Apache-2.0"
@@ -1,12 +1,14 @@
1
1
  import { IAdapter } from "./adapter.js";
2
- import { AdaptCommandChain, MergeCommandChain, PostCommandChain } from "./commands/command.js";
3
- import BaseApp from "../baseAppManager.js";
4
- import AppVariant from "../appVariantManager.js";
2
+ import { AdaptCommandChain, PostCommandChain, SetupCommandChain } from "./commands/command.js";
3
+ import BaseApp from "../baseApp.js";
4
+ import AppVariant from "../appVariant.js";
5
5
  import IAnnotationManager from "../annotations/annotationManager.js";
6
+ import { UI5BuilderTools } from "../model/types.js";
7
+ import IRepository from "../repositories/repository.js";
6
8
  export default class AbapAdapter implements IAdapter {
7
9
  private annotationManager;
8
10
  constructor(annotationManager: IAnnotationManager);
11
+ createSetupCommandChain(_appId: string, _repository: IRepository): SetupCommandChain;
9
12
  createAdaptCommandChain(baseApp: BaseApp, appVariant: AppVariant): AdaptCommandChain;
10
- createMergeCommandChain(baseApp: BaseApp, appVariant: AppVariant): MergeCommandChain;
11
- createPostCommandChain(): PostCommandChain;
13
+ createPostCommandChain(references: Map<string, string>, adaptationProject: AppVariant, ui5BuilderTools: UI5BuilderTools): PostCommandChain;
12
14
  }
@@ -1,5 +1,5 @@
1
- import { getCommonManifestUpdateCommands } from "./adapter.js";
2
- import { AdaptCommandChain, ManifestUpdateCommandChain, MergeCommandChain, PostCommandChain } from "./commands/command.js";
1
+ import { getCommonManifestUpdateCommands, getCommonPostCommands } from "./adapter.js";
2
+ import { AdaptCommandChain, ManifestUpdateCommandChain, PostCommandChain, SetupCommandChain } from "./commands/command.js";
3
3
  import DownloadAnnotationsCommand from "./commands/downloadAnnotationsCommand.js";
4
4
  import I18nPropertiesMergeCommand from "./commands/i18nPropertiesMergeCommand.js";
5
5
  export default class AbapAdapter {
@@ -7,28 +7,26 @@ export default class AbapAdapter {
7
7
  constructor(annotationManager) {
8
8
  this.annotationManager = annotationManager;
9
9
  }
10
+ createSetupCommandChain(_appId, _repository) {
11
+ return new SetupCommandChain([]);
12
+ }
10
13
  createAdaptCommandChain(baseApp, appVariant) {
11
14
  const appVariantIdHierarchyItem = {
12
15
  appVariantId: baseApp.id,
13
16
  version: baseApp.version,
14
17
  layer: "VENDOR"
15
18
  };
16
- return new AdaptCommandChain(baseApp.files, [
19
+ const manifestChanges = appVariant.getProcessedManifestChanges();
20
+ return new AdaptCommandChain(baseApp.files, appVariant.getProcessedFiles(), [
17
21
  new ManifestUpdateCommandChain([
18
22
  ...getCommonManifestUpdateCommands(baseApp, appVariant, appVariantIdHierarchyItem),
19
23
  ]),
20
24
  new DownloadAnnotationsCommand(appVariant.id, appVariant.prefix, this.annotationManager),
21
- ]);
22
- }
23
- createMergeCommandChain(baseApp, appVariant) {
24
- const manifestChanges = appVariant.getProcessedManifestChanges();
25
- return new MergeCommandChain(appVariant.getProcessedFiles(), [
26
25
  new I18nPropertiesMergeCommand(baseApp.i18nPath, appVariant.prefix, manifestChanges),
27
26
  ]);
28
27
  }
29
- createPostCommandChain() {
30
- // No post commands needed for ABAP, return an empty chain
31
- return new PostCommandChain([]);
28
+ createPostCommandChain(references, adaptationProject, ui5BuilderTools) {
29
+ return new PostCommandChain(getCommonPostCommands(references, adaptationProject, ui5BuilderTools));
32
30
  }
33
31
  }
34
32
  //# sourceMappingURL=abapAdapter.js.map
@@ -1,10 +1,14 @@
1
- import AppVariant from "../appVariantManager.js";
2
- import BaseApp from "../baseAppManager.js";
1
+ import AppVariant from "../appVariant.js";
2
+ import BaseApp from "../baseApp.js";
3
3
  import { IAppVariantIdHierarchyManifestItem } from "../model/appVariantIdHierarchyItem.js";
4
- import { AdaptCommandChain, ManifestUpdateCommand, MergeCommandChain, PostCommandChain } from "./commands/command.js";
4
+ import { UI5BuilderTools } from "../model/types.js";
5
+ import IRepository from "../repositories/repository.js";
6
+ import { AdaptCommandChain, IPromiseCommand, ManifestUpdateCommand, PostCommand, PostCommandChain, SetupCommandChain } from "./commands/command.js";
5
7
  export interface IAdapter {
8
+ createSetupCommandChain(appId: string, repository: IRepository): SetupCommandChain;
6
9
  createAdaptCommandChain(baseApp: BaseApp, appVariant: AppVariant): AdaptCommandChain;
7
- createMergeCommandChain(baseApp: BaseApp, appVariant: AppVariant): MergeCommandChain;
8
- createPostCommandChain(): PostCommandChain;
10
+ createPostCommandChain(references: Map<string, string>, adaptationProject: AppVariant, ui5BuilderTools: UI5BuilderTools): PostCommandChain;
9
11
  }
10
12
  export declare function getCommonManifestUpdateCommands(baseApp: BaseApp, appVariant: AppVariant, appVariantIdHierarchyItem: IAppVariantIdHierarchyManifestItem): ManifestUpdateCommand[];
13
+ export declare function getCommonPostCommands(references: Map<string, string>, adaptationProject: AppVariant, ui5BuilderTools: UI5BuilderTools): PostCommand[];
14
+ export declare function dependsOn<T>(promise: IPromiseCommand<T> | null): Promise<T>;
@@ -1,8 +1,12 @@
1
1
  import AddAppVariantIdHierarchyCommand from "./commands/addAppVariantIdHierarchyCommand.js";
2
2
  import ApplyDescriptorChangesCommand from "./commands/applyDescriptorChangesCommand.js";
3
+ import FilterFilesCommand from "./commands/filterFilesCommand.js";
4
+ import OmitDeletedResourcesCommand from "./commands/omitDeletedResourcesCommand.js";
5
+ import RenameFilesCommand from "./commands/renameFilesCommand.js";
3
6
  import SetAppVariantIdCommand from "./commands/setAppVariantIdCommand.js";
4
7
  import UpdateCloudDevAdaptationCommand from "./commands/updateCloudDevAdaptationCommand.js";
5
8
  import UpdateComponentNameCommand from "./commands/updateComponentNameCommand.js";
9
+ import WriteResourcesCommand from "./commands/writeResourcesCommand.js";
6
10
  export function getCommonManifestUpdateCommands(baseApp, appVariant, appVariantIdHierarchyItem) {
7
11
  const manifestChanges = appVariant.getProcessedManifestChanges();
8
12
  return [
@@ -13,4 +17,20 @@ export function getCommonManifestUpdateCommands(baseApp, appVariant, appVariantI
13
17
  new UpdateCloudDevAdaptationCommand(),
14
18
  ];
15
19
  }
20
+ export function getCommonPostCommands(references, adaptationProject, ui5BuilderTools) {
21
+ const { movedFiles, resources } = adaptationProject;
22
+ const { workspace, taskUtil, projectNamespace } = ui5BuilderTools;
23
+ return [
24
+ new FilterFilesCommand(),
25
+ new RenameFilesCommand(references),
26
+ new OmitDeletedResourcesCommand(taskUtil, movedFiles, resources, projectNamespace),
27
+ new WriteResourcesCommand(workspace, projectNamespace),
28
+ ];
29
+ }
30
+ export function dependsOn(promise) {
31
+ if (!promise) {
32
+ throw new Error("Dependent command was not executed, promise is not available");
33
+ }
34
+ return promise.result;
35
+ }
16
36
  //# sourceMappingURL=adapter.js.map
@@ -1,12 +1,15 @@
1
1
  import { IConfiguration } from "../model/configuration.js";
2
2
  import { IAdapter } from "./adapter.js";
3
- import { AdaptCommandChain, MergeCommandChain, PostCommandChain } from "./commands/command.js";
4
- import BaseApp from "../baseAppManager.js";
5
- import AppVariant from "../appVariantManager.js";
3
+ import { AdaptCommandChain, PostCommandChain, SetupCommandChain } from "./commands/command.js";
4
+ import BaseApp from "../baseApp.js";
5
+ import AppVariant from "../appVariant.js";
6
+ import { UI5BuilderTools } from "../model/types.js";
7
+ import IRepository from "../repositories/repository.js";
6
8
  export default class CFAdapter implements IAdapter {
7
9
  private configuration;
10
+ private fetchEndpointsCommand;
8
11
  constructor(configuration: IConfiguration);
12
+ createSetupCommandChain(_appId: string, _repository: IRepository): SetupCommandChain;
9
13
  createAdaptCommandChain(baseApp: BaseApp, appVariant: AppVariant): AdaptCommandChain;
10
- createMergeCommandChain(baseApp: BaseApp, appVariant: AppVariant): MergeCommandChain;
11
- createPostCommandChain(): PostCommandChain;
14
+ createPostCommandChain(references: Map<string, string>, adaptationProject: AppVariant, ui5BuilderTools: UI5BuilderTools): PostCommandChain;
12
15
  }
@@ -1,36 +1,42 @@
1
- import { getCommonManifestUpdateCommands } from "./adapter.js";
2
- import { AdaptCommandChain, ManifestUpdateCommandChain, MergeCommandChain, PostCommandChain } from "./commands/command.js";
1
+ import { dependsOn, getCommonManifestUpdateCommands, getCommonPostCommands } from "./adapter.js";
2
+ import { AdaptCommandChain, ManifestUpdateCommandChain, PostCommandChain, SetupCommandChain } from "./commands/command.js";
3
3
  import XsAppJsonEnhanceRoutesCommand from "./commands/xsAppJsonEnhanceRoutesCommand.js";
4
4
  import UpdateCloudPlatformCommand from "./commands/updateCloudPlatformCommand.js";
5
5
  import I18nPropertiesMergeCommand from "./commands/i18nPropertiesMergeCommand.js";
6
6
  import XsAppJsonMergeCommand from "./commands/xsAppJsonMergeCommand.js";
7
+ import FetchEndpointsCommand from "./commands/fetchEndpointsCommand.js";
7
8
  export default class CFAdapter {
8
9
  configuration;
10
+ fetchEndpointsCommand = null;
9
11
  constructor(configuration) {
10
12
  this.configuration = configuration;
11
13
  }
14
+ createSetupCommandChain(_appId, _repository) {
15
+ this.fetchEndpointsCommand = new FetchEndpointsCommand(this.configuration);
16
+ return new SetupCommandChain([
17
+ this.fetchEndpointsCommand
18
+ ]);
19
+ }
12
20
  createAdaptCommandChain(baseApp, appVariant) {
13
21
  const appVariantIdHierarchyItem = {
14
22
  appVariantId: baseApp.id,
15
23
  version: baseApp.version
16
24
  };
17
- return new AdaptCommandChain(baseApp.files, [
25
+ const manifestChanges = appVariant.getProcessedManifestChanges();
26
+ return new AdaptCommandChain(baseApp.files, appVariant.getProcessedFiles(), [
18
27
  new ManifestUpdateCommandChain([
19
28
  ...getCommonManifestUpdateCommands(baseApp, appVariant, appVariantIdHierarchyItem),
20
29
  new UpdateCloudPlatformCommand(this.configuration.sapCloudService),
21
30
  ]),
22
- ]);
23
- }
24
- createMergeCommandChain(baseApp, appVariant) {
25
- const manifestChanges = appVariant.getProcessedManifestChanges();
26
- return new MergeCommandChain(appVariant.getProcessedFiles(), [
27
31
  new I18nPropertiesMergeCommand(baseApp.i18nPath, appVariant.prefix, manifestChanges),
28
32
  new XsAppJsonMergeCommand(),
29
33
  ]);
30
34
  }
31
- createPostCommandChain() {
35
+ createPostCommandChain(references, adaptationProject, ui5BuilderTools) {
36
+ const serviceCredentialsPromise = dependsOn(this.fetchEndpointsCommand);
32
37
  return new PostCommandChain([
33
- new XsAppJsonEnhanceRoutesCommand(this.configuration),
38
+ new XsAppJsonEnhanceRoutesCommand(serviceCredentialsPromise),
39
+ ...getCommonPostCommands(references, adaptationProject, ui5BuilderTools)
34
40
  ]);
35
41
  }
36
42
  }
@@ -1,3 +1,18 @@
1
+ export declare abstract class SetupCommand {
2
+ readonly commandType = "setup";
3
+ /**
4
+ * Executes the command
5
+ */
6
+ abstract execute(): Promise<void>;
7
+ }
8
+ export declare class SetupCommandChain {
9
+ private commands;
10
+ constructor(commands: SetupCommand[]);
11
+ /**
12
+ * Executes all commands in the chain
13
+ */
14
+ execute(): Promise<void>;
15
+ }
1
16
  export declare abstract class AdaptCommand {
2
17
  readonly commandType = "adapt";
3
18
  abstract accept(filename: string): boolean;
@@ -8,15 +23,6 @@ export declare abstract class AdaptCommand {
8
23
  */
9
24
  abstract execute(files: Map<string, string>, filename: string): Promise<void>;
10
25
  }
11
- export declare class AdaptCommandChain {
12
- private files;
13
- private commands;
14
- constructor(files: ReadonlyMap<string, string>, commands: AdaptCommand[]);
15
- /**
16
- * Executes all commands in the chain that accept the given filename
17
- */
18
- execute(): Promise<ReadonlyMap<string, string>>;
19
- }
20
26
  export declare abstract class MergeCommand {
21
27
  readonly commandType = "merge";
22
28
  abstract accept(filename: string): boolean;
@@ -28,20 +34,6 @@ export declare abstract class MergeCommand {
28
34
  */
29
35
  abstract execute(files: Map<string, string>, filename: string, appVariantContent: string): Promise<void>;
30
36
  }
31
- /**
32
- * CommandChain implements the Chain of Responsibility pattern
33
- * It manages a collection of commands and executes them in sequence
34
- */
35
- export declare class MergeCommandChain {
36
- private appVariantFiles;
37
- private commands;
38
- constructor(appVariantFiles: ReadonlyMap<string, string>, commands?: MergeCommand[]);
39
- /**
40
- * Executes all commands in the chain that accept the given filename
41
- * @param files - Map of all files being processed
42
- */
43
- execute(files: ReadonlyMap<string, string>): Promise<ReadonlyMap<string, string>>;
44
- }
45
37
  export declare abstract class ManifestUpdateCommand {
46
38
  readonly commandType = "manifestUpdate";
47
39
  /**
@@ -77,3 +69,14 @@ export declare class PostCommandChain {
77
69
  */
78
70
  execute(files: ReadonlyMap<string, string>): Promise<ReadonlyMap<string, string>>;
79
71
  }
72
+ export declare class AdaptCommandChain {
73
+ private files;
74
+ private appVariantFiles;
75
+ private adaptCommands;
76
+ private mergeCommands;
77
+ constructor(files: ReadonlyMap<string, string>, appVariantFiles: ReadonlyMap<string, string>, commands: (AdaptCommand | MergeCommand)[]);
78
+ execute(): Promise<ReadonlyMap<string, string>>;
79
+ }
80
+ export interface IPromiseCommand<T> {
81
+ result: Promise<T>;
82
+ }
@@ -1,62 +1,32 @@
1
- export class AdaptCommand {
2
- commandType = "adapt";
1
+ import { getLogger } from "@ui5/logger";
2
+ const log = getLogger("@ui5/task-adaptation::CommandChain");
3
+ export class SetupCommand {
4
+ commandType = "setup";
3
5
  }
4
- export class AdaptCommandChain {
5
- files;
6
+ export class SetupCommandChain {
6
7
  commands;
7
- constructor(files, commands) {
8
- this.files = files;
8
+ constructor(commands) {
9
9
  this.commands = commands;
10
10
  }
11
11
  /**
12
- * Executes all commands in the chain that accept the given filename
12
+ * Executes all commands in the chain
13
13
  */
14
14
  async execute() {
15
- const filesCopy = new Map(this.files);
16
- for (const [filename] of filesCopy) {
17
- for (const command of this.commands) {
18
- if (command.accept(filename)) {
19
- await command.execute(filesCopy, filename);
20
- }
21
- }
15
+ const timings = [];
16
+ for (const command of this.commands) {
17
+ const start = performance.now();
18
+ await command.execute();
19
+ pushTiming(command, timings, start);
22
20
  }
23
- return filesCopy;
21
+ logTimings(this, timings);
24
22
  }
25
23
  }
24
+ export class AdaptCommand {
25
+ commandType = "adapt";
26
+ }
26
27
  export class MergeCommand {
27
28
  commandType = "merge";
28
29
  }
29
- /**
30
- * CommandChain implements the Chain of Responsibility pattern
31
- * It manages a collection of commands and executes them in sequence
32
- */
33
- export class MergeCommandChain {
34
- appVariantFiles;
35
- commands;
36
- constructor(appVariantFiles, commands = []) {
37
- this.appVariantFiles = appVariantFiles;
38
- this.commands = commands;
39
- }
40
- /**
41
- * Executes all commands in the chain that accept the given filename
42
- * @param files - Map of all files being processed
43
- */
44
- async execute(files) {
45
- const filesCopy = new Map(files);
46
- for (const [filename, appVariantContent] of this.appVariantFiles) {
47
- const acceptedCommands = this.commands.filter(command => command.accept(filename));
48
- if (acceptedCommands.length > 0) {
49
- for (const command of acceptedCommands) {
50
- await command.execute(filesCopy, filename, appVariantContent);
51
- }
52
- }
53
- else {
54
- filesCopy.set(filename, appVariantContent);
55
- }
56
- }
57
- return filesCopy;
58
- }
59
- }
60
30
  export class ManifestUpdateCommand {
61
31
  commandType = "manifestUpdate";
62
32
  }
@@ -73,10 +43,14 @@ export class ManifestUpdateCommandChain extends AdaptCommand {
73
43
  throw new Error("Original application should have manifest.json in root folder");
74
44
  }
75
45
  const manifest = JSON.parse(manifestContent);
46
+ const timings = [];
76
47
  for (const command of this.commands) {
48
+ const start = performance.now();
77
49
  await command.execute(manifest);
50
+ pushTiming(command, timings, start);
78
51
  }
79
52
  files.set(filename, JSON.stringify(manifest));
53
+ logTimings(this, timings);
80
54
  }
81
55
  }
82
56
  export class PostCommand {
@@ -97,10 +71,63 @@ export class PostCommandChain {
97
71
  */
98
72
  async execute(files) {
99
73
  const filesCopy = new Map(files);
74
+ const timings = [];
100
75
  for (const command of this.commands) {
76
+ const start = performance.now();
101
77
  await command.execute(filesCopy);
78
+ pushTiming(command, timings, start);
79
+ }
80
+ logTimings(this, timings);
81
+ return filesCopy;
82
+ }
83
+ }
84
+ export class AdaptCommandChain {
85
+ files;
86
+ appVariantFiles;
87
+ adaptCommands;
88
+ mergeCommands;
89
+ constructor(files, appVariantFiles, commands) {
90
+ this.files = files;
91
+ this.appVariantFiles = appVariantFiles;
92
+ this.adaptCommands = commands.filter((c) => c.commandType === "adapt");
93
+ this.mergeCommands = commands.filter((c) => c.commandType === "merge");
94
+ }
95
+ async execute() {
96
+ const filesCopy = new Map(this.files);
97
+ const timings = [];
98
+ for (const command of this.adaptCommands) {
99
+ const start = performance.now();
100
+ for (const [filename] of filesCopy) {
101
+ if (command.accept(filename)) {
102
+ await command.execute(filesCopy, filename);
103
+ }
104
+ }
105
+ pushTiming(command, timings, start);
102
106
  }
107
+ for (const command of this.mergeCommands) {
108
+ const start = performance.now();
109
+ for (const [filename, appVariantContent] of this.appVariantFiles) {
110
+ if (command.accept(filename)) {
111
+ await command.execute(filesCopy, filename, appVariantContent);
112
+ }
113
+ }
114
+ pushTiming(command, timings, start);
115
+ }
116
+ for (const [filename, appVariantContent] of this.appVariantFiles) {
117
+ const accepted = this.mergeCommands.some(command => command.accept(filename));
118
+ if (!accepted) {
119
+ filesCopy.set(filename, appVariantContent);
120
+ }
121
+ }
122
+ logTimings(this, timings);
103
123
  return filesCopy;
104
124
  }
105
125
  }
126
+ function logTimings(chain, timings) {
127
+ log.info(`${chain.constructor.name}:`);
128
+ timings.forEach(({ name, duration }) => log.info(` ${name}: ${duration.toFixed(2)}ms`));
129
+ }
130
+ function pushTiming(command, timings, start) {
131
+ timings.push({ name: command.constructor.name, duration: performance.now() - start });
132
+ }
106
133
  //# sourceMappingURL=command.js.map
@@ -0,0 +1,9 @@
1
+ import { IConfiguration } from "../../model/configuration.js";
2
+ import { ServiceCredentials } from "../../model/types.js";
3
+ import { IPromiseCommand, SetupCommand } from "./command.js";
4
+ export default class FetchEndpointsCommand extends SetupCommand implements IPromiseCommand<ServiceCredentials | undefined> {
5
+ private configuration;
6
+ result: Promise<ServiceCredentials | undefined>;
7
+ constructor(configuration: IConfiguration);
8
+ execute(): Promise<void>;
9
+ }
@@ -0,0 +1,21 @@
1
+ import CFUtil from "../../util/cfUtil.js";
2
+ import { validateObject } from "../../util/commonUtil.js";
3
+ import { SetupCommand } from "./command.js";
4
+ export default class FetchEndpointsCommand extends SetupCommand {
5
+ configuration;
6
+ result = Promise.resolve(undefined);
7
+ constructor(configuration) {
8
+ super();
9
+ this.configuration = configuration;
10
+ }
11
+ async execute() {
12
+ validateObject(this.configuration, ["serviceInstanceName"], "should be specified in ui5.yaml configuration");
13
+ const { serviceInstanceName, space } = this.configuration;
14
+ // Get valid service keys with proper endpoints structure
15
+ this.result = CFUtil.getOrCreateServiceKeyWithEndpoints(serviceInstanceName, space).catch(error => {
16
+ const errorText = error instanceof Error ? error.message : String(error);
17
+ throw new Error(`Failed to get a service key with endpoints for service instance '${serviceInstanceName}' in space '${space}': ${errorText}`);
18
+ });
19
+ }
20
+ }
21
+ //# sourceMappingURL=fetchEndpointsCommand.js.map
@@ -0,0 +1,15 @@
1
+ import { IPromiseCommand, SetupCommand } from "./command.js";
2
+ import { FetchFilesPromise } from "../../model/types.js";
3
+ import IRepository from "../../repositories/repository.js";
4
+ export default class FetchPreviewResourcesCommand extends SetupCommand implements IPromiseCommand<FetchFilesPromise | undefined> {
5
+ private appId;
6
+ private repository;
7
+ result: Promise<FetchFilesPromise | undefined>;
8
+ constructor(appId: string, repository: IRepository);
9
+ execute(): Promise<void>;
10
+ private preparePreview;
11
+ private printMessages;
12
+ private preReadLibs;
13
+ private moveLibraryFiles;
14
+ private modifyRoutes;
15
+ }
@@ -0,0 +1,103 @@
1
+ import FsUtil from "../../util/fsUtil.js";
2
+ import { posix as path } from "path";
3
+ import { SetupCommand } from "./command.js";
4
+ import { getLogger } from "@ui5/logger";
5
+ import { REUSE_DIR } from "../../model/configuration.js";
6
+ const log = getLogger("@ui5/task-adaptation::FetchPreviewResourcesCommand");
7
+ export default class FetchPreviewResourcesCommand extends SetupCommand {
8
+ appId;
9
+ repository;
10
+ result = Promise.resolve(undefined);
11
+ constructor(appId, repository) {
12
+ super();
13
+ this.appId = appId;
14
+ this.repository = repository;
15
+ }
16
+ async execute() {
17
+ this.result = this.preparePreview();
18
+ }
19
+ async preparePreview() {
20
+ let ui5AppInfo = "";
21
+ try {
22
+ ui5AppInfo = await FsUtil.readInProject("ui5AppInfo.json", "utf-8");
23
+ }
24
+ catch (error) {
25
+ throw new Error(`ui5AppInfo.json is missing in project root, cannot process preview resources: ${error instanceof Error ? error.message : String(error)}`);
26
+ }
27
+ // If no ui5AppInfo is provided, no preview processing is needed
28
+ if (!ui5AppInfo) {
29
+ log.verbose("No ui5AppInfo provided, skipping preview resources processing.");
30
+ return new Map();
31
+ }
32
+ const appInfo = JSON.parse(ui5AppInfo)[this.appId];
33
+ if (!appInfo) {
34
+ throw new Error(`No app info found for original app id '${this.appId}' in ui5AppInfo.json`);
35
+ }
36
+ this.printMessages(appInfo.messages);
37
+ const reuseLibs = appInfo.asyncHints.libs.filter(lib => lib.html5AppHostId && lib.html5AppName && lib.html5AppVersion);
38
+ if (reuseLibs.length > 0) {
39
+ return this.preReadLibs(reuseLibs, this.repository);
40
+ }
41
+ log.verbose("No reuse libraries defined in ui5AppInfo.json for preview");
42
+ return new Map();
43
+ }
44
+ printMessages(appInfoMessages) {
45
+ const logMap = {
46
+ Error: log.error,
47
+ Warning: log.warning,
48
+ Info: log.info,
49
+ debug: log.verbose
50
+ };
51
+ appInfoMessages.forEach((message) => {
52
+ const logger = logMap[message.severity] || log.info;
53
+ logger(`ui5AppInfo.json: ${message.severity} Message: ${message.message} (Error Code: ${message.errorCode})`);
54
+ });
55
+ }
56
+ preReadLibs(reuseLibs, repository) {
57
+ const promises = new Map();
58
+ reuseLibs.forEach(lib => {
59
+ log.info(`Downloading reuse library '${lib.html5AppName}' version '${lib.html5AppVersion}'`);
60
+ const resource = {
61
+ appName: lib.html5AppName,
62
+ appVersion: lib.html5AppVersion,
63
+ appHostId: lib.html5AppHostId,
64
+ cacheBusterToken: Promise.resolve(lib.html5CacheBusterToken)
65
+ };
66
+ const promise = repository
67
+ .fetch(resource)
68
+ .then((libFiles) => this.moveLibraryFiles(libFiles, lib.html5AppName, lib.name));
69
+ promises.set(lib.html5AppName, promise);
70
+ });
71
+ return promises;
72
+ }
73
+ moveLibraryFiles(inputFiles, libraryName, libId) {
74
+ const files = new Map();
75
+ inputFiles.forEach((content, filename) => {
76
+ const newFilename = path.join(libraryName, filename);
77
+ // Source path in xs-app.json needs to be adjusted to new location
78
+ if (filename.includes("xs-app.json")) {
79
+ const modified = this.modifyRoutes(content.toString("utf8"), libraryName, libId);
80
+ content = Buffer.from(modified, "utf8");
81
+ }
82
+ files.set(newFilename, content);
83
+ });
84
+ return files;
85
+ }
86
+ ;
87
+ modifyRoutes(xsAppJson, libName, libId) {
88
+ const xsApp = JSON.parse(xsAppJson);
89
+ xsApp.routes = xsApp.routes.map((route) => {
90
+ route.source = route.source.replace(new RegExp("^\\^\\/?(resources/)?"), `^/resources/${libId.replaceAll(".", "/")}/`);
91
+ if (route.service === "html5-apps-repo-rt") {
92
+ route = {
93
+ source: route.source,
94
+ target: route.target,
95
+ localDir: [REUSE_DIR, libName].join("/")
96
+ };
97
+ }
98
+ return route;
99
+ });
100
+ return JSON.stringify(xsApp);
101
+ }
102
+ }
103
+ //# sourceMappingURL=fetchPreviewResourcesCommand.js.map
@@ -0,0 +1,4 @@
1
+ import { PostCommand } from "./command.js";
2
+ export default class FilterFilesCommand extends PostCommand {
3
+ execute(files: Map<string, string>): Promise<void>;
4
+ }
@@ -0,0 +1,22 @@
1
+ import { PostCommand } from "./command.js";
2
+ export default class FilterFilesCommand extends PostCommand {
3
+ async execute(files) {
4
+ const IGNORE_FILES = ["manifest.appdescr_variant"];
5
+ const shouldIgnore = (filename, content) => {
6
+ if (filename.endsWith(".change")) {
7
+ return JSON.parse(content).changeType?.startsWith("appdescr_"); // validate JSON
8
+ }
9
+ return IGNORE_FILES.includes(filename);
10
+ };
11
+ const toDelete = [];
12
+ for (const [filename, content] of files) {
13
+ if (shouldIgnore(filename, content)) {
14
+ toDelete.push(filename);
15
+ }
16
+ }
17
+ for (const filename of toDelete) {
18
+ files.delete(filename);
19
+ }
20
+ }
21
+ }
22
+ //# sourceMappingURL=filterFilesCommand.js.map
@@ -0,0 +1,10 @@
1
+ import TaskUtil from "@ui5/project/build/helpers/TaskUtil";
2
+ import { PostCommand } from "./command.js";
3
+ export default class OmitDeletedResourcesCommand extends PostCommand {
4
+ private taskUtil;
5
+ private movedFiles;
6
+ private resources;
7
+ private projectNamespace;
8
+ constructor(taskUtil: TaskUtil, movedFiles: Map<string, string>, resources: ReadonlyArray<Resource> | undefined, projectNamespace: string);
9
+ execute(files: Map<string, string>): Promise<void>;
10
+ }