@ui5/task-adaptation 1.6.0 → 1.6.1

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 (74) hide show
  1. package/CHANGELOG.md +28 -9
  2. package/dist/adapters/abapAdapter.d.ts +14 -0
  3. package/dist/adapters/abapAdapter.js +45 -0
  4. package/dist/adapters/adapter.d.ts +8 -0
  5. package/dist/adapters/adapter.js +2 -0
  6. package/dist/adapters/cfAdapter.d.ts +12 -0
  7. package/dist/adapters/cfAdapter.js +46 -0
  8. package/dist/adapters/commands/addAppVariantIdHierarchyCommand.d.ts +7 -0
  9. package/dist/adapters/commands/addAppVariantIdHierarchyCommand.js +17 -0
  10. package/dist/adapters/commands/applyDescriptorChangesCommand.d.ts +10 -0
  11. package/dist/adapters/commands/applyDescriptorChangesCommand.js +43 -0
  12. package/dist/adapters/commands/command.d.ts +84 -0
  13. package/dist/adapters/commands/command.js +108 -0
  14. package/dist/adapters/commands/downloadAnnotationsCommand.d.ts +12 -0
  15. package/dist/adapters/commands/downloadAnnotationsCommand.js +26 -0
  16. package/dist/{util/i18nMerger.d.ts → adapters/commands/i18nPropertiesMergeCommand.d.ts} +13 -10
  17. package/dist/{util/i18nMerger.js → adapters/commands/i18nPropertiesMergeCommand.js} +30 -27
  18. package/dist/adapters/commands/setAppVariantIdCommand.d.ts +7 -0
  19. package/dist/adapters/commands/setAppVariantIdCommand.js +15 -0
  20. package/dist/adapters/commands/updateCloudDevAdaptationCommand.d.ts +4 -0
  21. package/dist/adapters/commands/updateCloudDevAdaptationCommand.js +11 -0
  22. package/dist/adapters/commands/updateCloudPlatformCommand.d.ts +6 -0
  23. package/dist/adapters/commands/updateCloudPlatformCommand.js +23 -0
  24. package/dist/adapters/commands/updateComponentNameCommand.d.ts +6 -0
  25. package/dist/adapters/commands/updateComponentNameCommand.js +13 -0
  26. package/dist/adapters/commands/xsAppJsonEnhanceRoutesCommand.d.ts +7 -0
  27. package/dist/adapters/commands/xsAppJsonEnhanceRoutesCommand.js +36 -0
  28. package/dist/adapters/commands/xsAppJsonMergeCommand.d.ts +5 -0
  29. package/dist/adapters/commands/xsAppJsonMergeCommand.js +17 -0
  30. package/dist/adapters/previewAdapter.d.ts +6 -0
  31. package/dist/adapters/previewAdapter.js +8 -0
  32. package/dist/appVariantManager.js +3 -0
  33. package/dist/baseAppManager.d.ts +0 -8
  34. package/dist/baseAppManager.js +3 -69
  35. package/dist/bundle.js +37 -35
  36. package/dist/cache/cacheHolder.js +9 -4
  37. package/dist/index.js +7 -3
  38. package/dist/model/appVariantIdHierarchyItem.d.ts +6 -1
  39. package/dist/model/types.d.ts +6 -0
  40. package/dist/previewManager.js +16 -23
  41. package/dist/processors/abapProcessor.d.ts +3 -7
  42. package/dist/processors/abapProcessor.js +4 -15
  43. package/dist/processors/cfProcessor.d.ts +5 -11
  44. package/dist/processors/cfProcessor.js +4 -90
  45. package/dist/processors/previewProcessor.d.ts +8 -0
  46. package/dist/processors/previewProcessor.js +11 -0
  47. package/dist/processors/processor.d.ts +3 -3
  48. package/dist/processors/processor.js +9 -0
  49. package/dist/repositories/abapRepoManager.d.ts +1 -1
  50. package/dist/repositories/html5RepoManager.js +6 -0
  51. package/dist/util/cf/xsAppJsonUtil.d.ts +13 -0
  52. package/dist/util/cf/xsAppJsonUtil.js +81 -0
  53. package/dist/util/cfUtil.d.ts +3 -3
  54. package/dist/util/cfUtil.js +1 -1
  55. package/dist/util/filesUtil.d.ts +3 -2
  56. package/dist/util/filesUtil.js +20 -4
  57. package/dist/util/fsUtil.d.ts +9 -0
  58. package/dist/util/fsUtil.js +40 -0
  59. package/dist/util/movingHandler/changeFileMoveHandler.js +2 -3
  60. package/dist/util/objectPath.d.ts +19 -0
  61. package/dist/util/objectPath.js +62 -0
  62. package/dist/util/renamingHandlers/jsonRenamingHandler.d.ts +12 -0
  63. package/dist/util/renamingHandlers/jsonRenamingHandler.js +34 -0
  64. package/dist/util/renamingHandlers/manifestRenamingHandler.d.ts +4 -5
  65. package/dist/util/renamingHandlers/manifestRenamingHandler.js +7 -18
  66. package/dist/util/requestUtil.d.ts +1 -1
  67. package/dist/util/requestUtil.js +5 -2
  68. package/dist/util/resourceUtil.d.ts +0 -7
  69. package/dist/util/resourceUtil.js +0 -36
  70. package/package.json +3 -2
  71. package/dist/util/movingHandler/fileMoveHandler.d.ts +0 -8
  72. package/dist/util/movingHandler/fileMoveHandler.js +0 -77
  73. package/scripts/publish.ts +0 -256
  74. package/scripts/test-integration-prep.sh +0 -4
package/CHANGELOG.md CHANGED
@@ -2,16 +2,31 @@
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.0...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task-adaptation/compare/v1.6.1...HEAD).
6
+
7
+ <a name="v1.6.1"></a>
8
+ ## [v1.6.1] - 0001-01-01
6
9
 
7
10
  <a name="v1.6.0"></a>
8
- ## [v1.6.0] - 2026-02-02
11
+ ## [v1.6.0] - 2026-02-26
12
+
13
+ <a name="v0.2.0"></a>
14
+ ## [v0.2.0] - 2026-02-20
15
+
16
+ <a name="v0.1.0"></a>
17
+ ## [v0.1.0] - 2026-02-20
9
18
 
10
- <a name="v1.5.2-rc.1"></a>
11
- ## [v1.5.2-rc.1] - 2025-08-22
19
+ <a name="v1.5.4"></a>
20
+ ## [v1.5.4] - 2026-02-16
21
+
22
+ <a name="v1.5.3"></a>
23
+ ## [v1.5.3] - 2025-09-29
24
+
25
+ <a name="v1.5.2"></a>
26
+ ## [v1.5.2] - 2025-08-25
27
+ ### Bug Fixes
28
+ - Removed moved changes [`babdc1b`](https://github.com/SAP/ui5-task-adaptation/commit/babdc1bce8e407b2638e014cfaa4e6547bba10ac)
12
29
 
13
- <a name="v1.5.2-rc.0"></a>
14
- ## [v1.5.2-rc.0] - 2025-08-19
15
30
 
16
31
  <a name="v1.5.1"></a>
17
32
  ## [v1.5.1] - 2025-08-06
@@ -128,9 +143,13 @@ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task
128
143
  <a name="v1.0.0"></a>
129
144
  ## v1.0.0 - 2020-12-09
130
145
 
131
- [v1.6.0]: https://github.com/SAP/ui5-task-adaptation/compare/v1.5.2-rc.1...v1.6.0
132
- [v1.5.2-rc.1]: https://github.com/SAP/ui5-task-adaptation/compare/v1.5.2-rc.0...v1.5.2-rc.1
133
- [v1.5.2-rc.0]: https://github.com/SAP/ui5-task-adaptation/compare/v1.5.1...v1.5.2-rc.0
146
+ [v1.6.1]: https://github.com/SAP/ui5-task-adaptation/compare/v1.6.0...v1.6.1
147
+ [v1.6.0]: https://github.com/SAP/ui5-task-adaptation/compare/v0.2.0...v1.6.0
148
+ [v0.2.0]: https://github.com/SAP/ui5-task-adaptation/compare/v0.1.0...v0.2.0
149
+ [v0.1.0]: https://github.com/SAP/ui5-task-adaptation/compare/v1.5.4...v0.1.0
150
+ [v1.5.4]: https://github.com/SAP/ui5-task-adaptation/compare/v1.5.3...v1.5.4
151
+ [v1.5.3]: https://github.com/SAP/ui5-task-adaptation/compare/v1.5.2...v1.5.3
152
+ [v1.5.2]: https://github.com/SAP/ui5-task-adaptation/compare/v1.5.1...v1.5.2
134
153
  [v1.5.1]: https://github.com/SAP/ui5-task-adaptation/compare/v1.4.3...v1.5.1
135
154
  [v1.4.3]: https://github.com/SAP/ui5-task-adaptation/compare/v1.4.2...v1.4.3
136
155
  [v1.4.2]: https://github.com/SAP/ui5-task-adaptation/compare/v1.4.0...v1.4.2
@@ -0,0 +1,14 @@
1
+ import { IConfiguration } from "../model/configuration.js";
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";
6
+ import AnnotationManager from "../annotationManager.js";
7
+ export default class AbapAdapter implements IAdapter {
8
+ private configuration;
9
+ private annotationManager;
10
+ constructor(configuration: IConfiguration, annotationManager: AnnotationManager);
11
+ createAdaptCommandChain(baseApp: BaseApp, appVariant: AppVariant): AdaptCommandChain;
12
+ createMergeCommandChain(baseApp: BaseApp, appVariant: AppVariant): MergeCommandChain;
13
+ createPostCommandChain(): PostCommandChain;
14
+ }
@@ -0,0 +1,45 @@
1
+ import { AdaptCommandChain, ManifestUpdateCommandChain, MergeCommandChain, PostCommandChain } from "./commands/command.js";
2
+ import AddAppVariantIdHierarchyCommand from "./commands/addAppVariantIdHierarchyCommand.js";
3
+ import ApplyDescriptorChangesCommand from "./commands/applyDescriptorChangesCommand.js";
4
+ import SetAppVariantIdCommand from "./commands/setAppVariantIdCommand.js";
5
+ import UpdateComponentNameCommand from "./commands/updateComponentNameCommand.js";
6
+ import DownloadAnnotationsCommand from "./commands/downloadAnnotationsCommand.js";
7
+ import I18nPropertiesMergeCommand from "./commands/i18nPropertiesMergeCommand.js";
8
+ import UpdateCloudDevAdaptationCommand from "./commands/updateCloudDevAdaptationCommand.js";
9
+ export default class AbapAdapter {
10
+ configuration;
11
+ annotationManager;
12
+ constructor(configuration, annotationManager) {
13
+ this.configuration = configuration;
14
+ this.annotationManager = annotationManager;
15
+ }
16
+ createAdaptCommandChain(baseApp, appVariant) {
17
+ const manifestChanges = appVariant.getProcessedManifestChanges();
18
+ const appVariantIdHierarchyItem = {
19
+ appVariantId: baseApp.id,
20
+ version: baseApp.version,
21
+ layer: "VENDOR"
22
+ };
23
+ return new AdaptCommandChain(baseApp.files, [
24
+ new ManifestUpdateCommandChain([
25
+ new SetAppVariantIdCommand(appVariant.id),
26
+ new UpdateComponentNameCommand(baseApp.id),
27
+ new ApplyDescriptorChangesCommand(manifestChanges, appVariant.prefix),
28
+ new AddAppVariantIdHierarchyCommand(appVariantIdHierarchyItem),
29
+ new UpdateCloudDevAdaptationCommand(),
30
+ ]),
31
+ new DownloadAnnotationsCommand(appVariant.id, appVariant.prefix, this.annotationManager, this.configuration),
32
+ ]);
33
+ }
34
+ createMergeCommandChain(baseApp, appVariant) {
35
+ const manifestChanges = appVariant.getProcessedManifestChanges();
36
+ return new MergeCommandChain([
37
+ new I18nPropertiesMergeCommand(baseApp.i18nPath, appVariant.prefix, manifestChanges),
38
+ ]);
39
+ }
40
+ createPostCommandChain() {
41
+ // No post commands needed for ABAP, return an empty chain
42
+ return new PostCommandChain([]);
43
+ }
44
+ }
45
+ //# sourceMappingURL=abapAdapter.js.map
@@ -0,0 +1,8 @@
1
+ import AppVariant from "../appVariantManager.js";
2
+ import BaseApp from "../baseAppManager.js";
3
+ import { AdaptCommandChain, MergeCommandChain, PostCommandChain } from "./commands/command.js";
4
+ export interface IAdapter {
5
+ createAdaptCommandChain(baseApp: BaseApp, appVariant: AppVariant): AdaptCommandChain;
6
+ createMergeCommandChain(baseApp: BaseApp, appVariant: AppVariant): MergeCommandChain;
7
+ createPostCommandChain(): PostCommandChain;
8
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1,12 @@
1
+ import { IConfiguration } from "../model/configuration.js";
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";
6
+ export default class CFAdapter implements IAdapter {
7
+ private configuration;
8
+ constructor(configuration: IConfiguration);
9
+ createAdaptCommandChain(baseApp: BaseApp, appVariant: AppVariant): AdaptCommandChain;
10
+ createMergeCommandChain(baseApp: BaseApp, appVariant: AppVariant): MergeCommandChain;
11
+ createPostCommandChain(): PostCommandChain;
12
+ }
@@ -0,0 +1,46 @@
1
+ import { AdaptCommandChain, ManifestUpdateCommandChain, MergeCommandChain, PostCommandChain } from "./commands/command.js";
2
+ import XsAppJsonEnhanceRoutesCommand from "./commands/xsAppJsonEnhanceRoutesCommand.js";
3
+ import AddAppVariantIdHierarchyCommand from "./commands/addAppVariantIdHierarchyCommand.js";
4
+ import UpdateCloudDevAdaptationCommand from "./commands/updateCloudDevAdaptationCommand.js";
5
+ import UpdateCloudPlatformCommand from "./commands/updateCloudPlatformCommand.js";
6
+ import ApplyDescriptorChangesCommand from "./commands/applyDescriptorChangesCommand.js";
7
+ import SetAppVariantIdCommand from "./commands/setAppVariantIdCommand.js";
8
+ import UpdateComponentNameCommand from "./commands/updateComponentNameCommand.js";
9
+ import I18nPropertiesMergeCommand from "./commands/i18nPropertiesMergeCommand.js";
10
+ import XsAppJsonMergeCommand from "./commands/xsAppJsonMergeCommand.js";
11
+ export default class CFAdapter {
12
+ configuration;
13
+ constructor(configuration) {
14
+ this.configuration = configuration;
15
+ }
16
+ createAdaptCommandChain(baseApp, appVariant) {
17
+ const manifestChanges = appVariant.getProcessedManifestChanges();
18
+ const appVariantIdHierarchyItem = {
19
+ appVariantId: baseApp.id,
20
+ version: baseApp.version
21
+ };
22
+ return new AdaptCommandChain(baseApp.files, [
23
+ new ManifestUpdateCommandChain([
24
+ new SetAppVariantIdCommand(appVariant.id),
25
+ new UpdateComponentNameCommand(baseApp.id),
26
+ new ApplyDescriptorChangesCommand(manifestChanges, appVariant.prefix),
27
+ new AddAppVariantIdHierarchyCommand(appVariantIdHierarchyItem),
28
+ new UpdateCloudDevAdaptationCommand(),
29
+ new UpdateCloudPlatformCommand(this.configuration.sapCloudService),
30
+ ]),
31
+ ]);
32
+ }
33
+ createMergeCommandChain(baseApp, appVariant) {
34
+ const manifestChanges = appVariant.getProcessedManifestChanges();
35
+ return new MergeCommandChain([
36
+ new I18nPropertiesMergeCommand(baseApp.i18nPath, appVariant.prefix, manifestChanges),
37
+ new XsAppJsonMergeCommand(),
38
+ ]);
39
+ }
40
+ createPostCommandChain() {
41
+ return new PostCommandChain([
42
+ new XsAppJsonEnhanceRoutesCommand(this.configuration),
43
+ ]);
44
+ }
45
+ }
46
+ //# sourceMappingURL=cfAdapter.js.map
@@ -0,0 +1,7 @@
1
+ import { ManifestUpdateCommand } from "./command.js";
2
+ import { IAppVariantIdHierarchyManifestItem } from "../../model/appVariantIdHierarchyItem.js";
3
+ export default class AddAppVariantIdHierarchyLayerCommand extends ManifestUpdateCommand {
4
+ private appVariantIdHierarchyItem;
5
+ constructor(appVariantIdHierarchyItem: IAppVariantIdHierarchyManifestItem);
6
+ execute(manifest: any): Promise<void>;
7
+ }
@@ -0,0 +1,17 @@
1
+ import { ManifestUpdateCommand } from "./command.js";
2
+ import { get } from "../../util/objectPath.js";
3
+ import { getLogger } from "@ui5/logger";
4
+ const log = getLogger("@ui5/task-adaptation::ApplyDescriptorChangesCommand");
5
+ export default class AddAppVariantIdHierarchyLayerCommand extends ManifestUpdateCommand {
6
+ appVariantIdHierarchyItem;
7
+ constructor(appVariantIdHierarchyItem) {
8
+ super();
9
+ this.appVariantIdHierarchyItem = appVariantIdHierarchyItem;
10
+ }
11
+ async execute(manifest) {
12
+ log.verbose(`Adding app variant ID hierarchy item for app variant ${this.appVariantIdHierarchyItem.appVariantId} to manifest`);
13
+ get(manifest, ["sap.ui5", "appVariantIdHierarchy"], [])
14
+ .unshift(this.appVariantIdHierarchyItem);
15
+ }
16
+ }
17
+ //# sourceMappingURL=addAppVariantIdHierarchyCommand.js.map
@@ -0,0 +1,10 @@
1
+ import { ManifestUpdateCommand } from "./command.js";
2
+ import { IChange } from "../../model/types.js";
3
+ export default class ApplyDescriptorChangesCommand extends ManifestUpdateCommand {
4
+ private manifestChanges;
5
+ private prefix;
6
+ constructor(manifestChanges: ReadonlyArray<IChange>, prefix: string);
7
+ execute(manifest: any): Promise<void>;
8
+ private applyDescriptorChanges;
9
+ private adjustAddNewModelEnhanceWith;
10
+ }
@@ -0,0 +1,43 @@
1
+ import BuildStrategy from "../../buildStrategy.js";
2
+ import { AppDescriptorChange, RawApplier, RegistrationBuild } from "../../../dist/bundle.js";
3
+ import { ManifestUpdateCommand } from "./command.js";
4
+ import { getLogger } from "@ui5/logger";
5
+ const log = getLogger("@ui5/task-adaptation::ApplyDescriptorChangesCommand");
6
+ export default class ApplyDescriptorChangesCommand extends ManifestUpdateCommand {
7
+ manifestChanges;
8
+ prefix;
9
+ constructor(manifestChanges, prefix) {
10
+ super();
11
+ this.manifestChanges = manifestChanges;
12
+ this.prefix = prefix;
13
+ }
14
+ async execute(manifest) {
15
+ await this.applyDescriptorChanges(manifest);
16
+ }
17
+ async applyDescriptorChanges(baseAppManifest) {
18
+ log.verbose("Applying appVariant changes");
19
+ const changesContent = new Array();
20
+ const i18nBundleName = this.prefix;
21
+ for (const change of this.manifestChanges) {
22
+ this.adjustAddNewModelEnhanceWith(change, i18nBundleName);
23
+ changesContent.push(new AppDescriptorChange(change));
24
+ }
25
+ if (changesContent.length > 0) {
26
+ const changeHandlers = await Promise.all(changesContent.map(change => RegistrationBuild[change.getChangeType()]()));
27
+ await RawApplier.applyChanges(changeHandlers, baseAppManifest, changesContent, new BuildStrategy());
28
+ }
29
+ }
30
+ adjustAddNewModelEnhanceWith(change, i18nBundleName) {
31
+ if (change.changeType === "appdescr_ui5_addNewModelEnhanceWith") {
32
+ if (change.texts == null) {
33
+ // We need to add texts properties to changes because not all
34
+ // have texts property. Changes without texts property can
35
+ // causes issues in bundle.js This is needed for now, and will
36
+ // be removed as soon as change merger in openUI5 is updated
37
+ change.texts = { i18n: change.content?.bundleUrl || "i18n/i18n.properties" };
38
+ }
39
+ change.texts.i18n = i18nBundleName + "/" + change.texts.i18n;
40
+ }
41
+ }
42
+ }
43
+ //# sourceMappingURL=applyDescriptorChangesCommand.js.map
@@ -0,0 +1,84 @@
1
+ export declare abstract class AdaptCommand {
2
+ readonly commandType = "adapt";
3
+ abstract accept(filename: string): boolean;
4
+ /**
5
+ * Executes the command on the specified file
6
+ * @param files - Map of all files being processed
7
+ * @param filename - The current file being processed
8
+ */
9
+ abstract execute(files: Map<string, string>, filename: string): Promise<void>;
10
+ }
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
+ * @param files - Map of all files being processed
18
+ * @param filename - The current file being processed
19
+ */
20
+ execute(): Promise<ReadonlyMap<string, string>>;
21
+ }
22
+ export declare abstract class MergeCommand {
23
+ readonly commandType = "merge";
24
+ abstract accept(filename: string): boolean;
25
+ /**
26
+ * Executes the command on the specified file
27
+ * @param files - Map of all files being processed
28
+ * @param filename - The current file being processed
29
+ * @param appVariantContent - Content from the app variant
30
+ */
31
+ abstract execute(files: Map<string, string>, filename: string, appVariantContent: string): Promise<void>;
32
+ }
33
+ /**
34
+ * CommandChain implements the Chain of Responsibility pattern
35
+ * It manages a collection of commands and executes them in sequence
36
+ */
37
+ export declare class MergeCommandChain {
38
+ private commands;
39
+ constructor(commands?: MergeCommand[]);
40
+ /**
41
+ * Executes all commands in the chain that accept the given filename
42
+ * @param files - Map of all files being processed
43
+ * @param filename - The current file being processed
44
+ * @param appVariantContent - Content from the app variant
45
+ */
46
+ execute(files: ReadonlyMap<string, string>, appVariantFiles: ReadonlyMap<string, string>): Promise<ReadonlyMap<string, string>>;
47
+ }
48
+ export declare abstract class ManifestUpdateCommand {
49
+ readonly commandType = "manifestUpdate";
50
+ /**
51
+ * The command modifies the manifest in-place.
52
+ * @param manifest base app manifest content as JSON object.
53
+ */
54
+ abstract execute(manifest: any): Promise<void>;
55
+ }
56
+ export declare class ManifestUpdateCommandChain extends AdaptCommand {
57
+ private commands;
58
+ constructor(commands?: ManifestUpdateCommand[]);
59
+ accept: (filename: string) => filename is "manifest.json";
60
+ execute(files: Map<string, string>, filename: string): Promise<void>;
61
+ }
62
+ export declare abstract class PostCommand {
63
+ readonly commandType = "post";
64
+ /**
65
+ * Executes the command on the specified file
66
+ * @param files - Map of all files being processed
67
+ * @param filename - The current file being processed
68
+ * @param appVariantContent - Content from the app variant
69
+ */
70
+ abstract execute(files: Map<string, string>): Promise<void>;
71
+ }
72
+ /**
73
+ * CommandChain implements the Chain of Responsibility pattern
74
+ * It manages a collection of commands and executes them in sequence
75
+ */
76
+ export declare class PostCommandChain {
77
+ protected commands: PostCommand[];
78
+ constructor(commands?: PostCommand[]);
79
+ /**
80
+ * Executes all commands in the chain that accept the given filename
81
+ * @param files - Map of all files being processed
82
+ */
83
+ execute(files: ReadonlyMap<string, string>): Promise<ReadonlyMap<string, string>>;
84
+ }
@@ -0,0 +1,108 @@
1
+ export class AdaptCommand {
2
+ commandType = "adapt";
3
+ }
4
+ export class AdaptCommandChain {
5
+ files;
6
+ commands;
7
+ constructor(files, commands) {
8
+ this.files = files;
9
+ this.commands = commands;
10
+ }
11
+ /**
12
+ * Executes all commands in the chain that accept the given filename
13
+ * @param files - Map of all files being processed
14
+ * @param filename - The current file being processed
15
+ */
16
+ async execute() {
17
+ const filesCopy = new Map(this.files);
18
+ for (const [filename] of filesCopy) {
19
+ for (const command of this.commands) {
20
+ if (command.accept(filename)) {
21
+ await command.execute(filesCopy, filename);
22
+ }
23
+ }
24
+ }
25
+ return filesCopy;
26
+ }
27
+ }
28
+ export class MergeCommand {
29
+ commandType = "merge";
30
+ }
31
+ /**
32
+ * CommandChain implements the Chain of Responsibility pattern
33
+ * It manages a collection of commands and executes them in sequence
34
+ */
35
+ export class MergeCommandChain {
36
+ commands;
37
+ constructor(commands = []) {
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
+ * @param filename - The current file being processed
44
+ * @param appVariantContent - Content from the app variant
45
+ */
46
+ async execute(files, appVariantFiles) {
47
+ const filesCopy = new Map(files);
48
+ for (const [filename, appVariantContent] of appVariantFiles) {
49
+ const acceptedCommands = this.commands.filter(command => command.accept(filename));
50
+ if (acceptedCommands.length > 0) {
51
+ for (const command of acceptedCommands) {
52
+ await command.execute(filesCopy, filename, appVariantContent);
53
+ }
54
+ }
55
+ else {
56
+ filesCopy.set(filename, appVariantContent);
57
+ }
58
+ }
59
+ return filesCopy;
60
+ }
61
+ }
62
+ export class ManifestUpdateCommand {
63
+ commandType = "manifestUpdate";
64
+ }
65
+ export class ManifestUpdateCommandChain extends AdaptCommand {
66
+ commands;
67
+ constructor(commands = []) {
68
+ super();
69
+ this.commands = commands;
70
+ }
71
+ accept = (filename) => filename === "manifest.json";
72
+ async execute(files, filename) {
73
+ const manifestContent = files.get(filename);
74
+ if (!manifestContent) {
75
+ throw new Error("Original application should have manifest.json in root folder");
76
+ }
77
+ const manifest = JSON.parse(manifestContent);
78
+ for (const command of this.commands) {
79
+ await command.execute(manifest);
80
+ }
81
+ files.set(filename, JSON.stringify(manifest));
82
+ }
83
+ }
84
+ export class PostCommand {
85
+ commandType = "post";
86
+ }
87
+ /**
88
+ * CommandChain implements the Chain of Responsibility pattern
89
+ * It manages a collection of commands and executes them in sequence
90
+ */
91
+ export class PostCommandChain {
92
+ commands;
93
+ constructor(commands = []) {
94
+ this.commands = commands;
95
+ }
96
+ /**
97
+ * Executes all commands in the chain that accept the given filename
98
+ * @param files - Map of all files being processed
99
+ */
100
+ async execute(files) {
101
+ const filesCopy = new Map(files);
102
+ for (const command of this.commands) {
103
+ await command.execute(filesCopy);
104
+ }
105
+ return filesCopy;
106
+ }
107
+ }
108
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1,12 @@
1
+ import AnnotationManager from "../../annotationManager.js";
2
+ import { IConfiguration } from "../../model/configuration.js";
3
+ import { AdaptCommand } from "./command.js";
4
+ export default class DownloadAnnotationsCommand extends AdaptCommand {
5
+ private appVariantId;
6
+ private prefix;
7
+ private annotationManager;
8
+ private configuration;
9
+ constructor(appVariantId: string, prefix: string, annotationManager: AnnotationManager, configuration: IConfiguration);
10
+ accept: (filename: string) => filename is "manifest.json";
11
+ execute(files: Map<string, string>, filename: string): Promise<void>;
12
+ }
@@ -0,0 +1,26 @@
1
+ import { AdaptCommand } from "./command.js";
2
+ import Language from "../../model/language.js";
3
+ export default class DownloadAnnotationsCommand extends AdaptCommand {
4
+ appVariantId;
5
+ prefix;
6
+ annotationManager;
7
+ configuration;
8
+ constructor(appVariantId, prefix, annotationManager, configuration) {
9
+ super();
10
+ this.appVariantId = appVariantId;
11
+ this.prefix = prefix;
12
+ this.annotationManager = annotationManager;
13
+ this.configuration = configuration;
14
+ }
15
+ accept = (filename) => filename === "manifest.json";
16
+ async execute(files, filename) {
17
+ const languages = Language.create(this.configuration.languages);
18
+ const baseAppManifest = JSON.parse(files.get(filename));
19
+ let newFiles = await this.annotationManager.process(baseAppManifest, languages, this.appVariantId, this.prefix);
20
+ if (newFiles) {
21
+ newFiles.forEach((value, key) => files.set(key, value));
22
+ }
23
+ files.set(filename, JSON.stringify(baseAppManifest));
24
+ }
25
+ }
26
+ //# sourceMappingURL=downloadAnnotationsCommand.js.map
@@ -1,11 +1,14 @@
1
- import AppVariant from "../appVariantManager.js";
2
- import { IChange } from "../model/types.js";
3
- export default class FileMerger {
4
- static analyzeAppVariantManifestChanges(manifestChanges: ReadonlyArray<IChange>): {
5
- mergePaths: RegExp[];
6
- copyPaths: RegExp[];
7
- };
8
- static merge(baseAppFiles: ReadonlyMap<string, string>, i18nPath: string, appVariant: AppVariant): Map<string, string>;
1
+ import { IChange } from "../../model/types.js";
2
+ import { MergeCommand } from "./command.js";
3
+ export default class I18nPropertiesMergeCommand extends MergeCommand {
4
+ private i18nPath;
5
+ private prefix;
6
+ private mergePaths;
7
+ private copyPaths;
8
+ constructor(i18nPath: string, prefix: string, manifestChanges: ReadonlyArray<IChange>);
9
+ accept: (filename: string) => boolean;
10
+ private analyzeAppVariantManifestChanges;
11
+ execute(files: Map<string, string>, filename: string, appVariantContent: string): Promise<void>;
9
12
  /**
10
13
  * Filters out specific lines from the given string.
11
14
  * Removes lines matching:
@@ -13,7 +16,7 @@ export default class FileMerger {
13
16
  * - ABAP_TRANSLATION
14
17
  * - SAPUI5 TRANSLATION-KEY
15
18
  */
16
- private static filterTranslationMetaLines;
19
+ private filterTranslationMetaLines;
17
20
  /**
18
21
  * Merge/Append base property file with property file from app variant
19
22
  * FIXME Currently merge could duplicate keys which causes undefined
@@ -22,5 +25,5 @@ export default class FileMerger {
22
25
  * app variant Id as prefix => If we filter on them we do not need to remove
23
26
  * existing overwritten keys (as there should be none)
24
27
  */
25
- private static mergePropertiesFiles;
28
+ private mergePropertiesFiles;
26
29
  }
@@ -1,7 +1,21 @@
1
- import { escapeRegex, trimExtension } from "./commonUtil.js";
1
+ import { escapeRegex, trimExtension } from "../../util/commonUtil.js";
2
2
  import { posix as path } from "path";
3
- export default class FileMerger {
4
- static analyzeAppVariantManifestChanges(manifestChanges) {
3
+ import { MergeCommand } from "./command.js";
4
+ export default class I18nPropertiesMergeCommand extends MergeCommand {
5
+ i18nPath;
6
+ prefix;
7
+ mergePaths;
8
+ copyPaths;
9
+ constructor(i18nPath, prefix, manifestChanges) {
10
+ super();
11
+ this.i18nPath = i18nPath;
12
+ this.prefix = prefix;
13
+ const { mergePaths, copyPaths } = this.analyzeAppVariantManifestChanges(manifestChanges);
14
+ this.mergePaths = mergePaths;
15
+ this.copyPaths = copyPaths;
16
+ }
17
+ accept = (filename) => filename.endsWith(".properties");
18
+ analyzeAppVariantManifestChanges(manifestChanges) {
5
19
  // check which files need to be copied and which files need to be merged and copied
6
20
  // this is necessary because lrep does not support multiple enhanceWith with multiple locations
7
21
  const TRANSLATION_REGEX_PATTERN = "((_[a-z]{2,3})?(_[a-zA-Z]{2,3}(_[a-zA-Z]{2,20})?)?)\.properties$";
@@ -23,28 +37,17 @@ export default class FileMerger {
23
37
  });
24
38
  return { mergePaths: Array.from(mergePaths), copyPaths: Array.from(copyPaths) };
25
39
  }
26
- static merge(baseAppFiles, i18nPath, appVariant) {
27
- const i18nTargetFolder = appVariant.prefix;
28
- const { copyPaths, mergePaths } = this.analyzeAppVariantManifestChanges(appVariant.getProcessedManifestChanges());
29
- const files = new Map(baseAppFiles);
30
- for (const [filename, content] of Array.from(appVariant.getProcessedFiles())) {
31
- if (filename.endsWith(".properties")) {
32
- // merge/copy logic
33
- // check if file matches with regex in merge/copy
34
- const mergePathMatch = mergePaths.map(path => filename.match(path)).find(match => match);
35
- const copyPathMatch = copyPaths.map(path => filename.match(path)).find(match => match);
36
- if (mergePathMatch) {
37
- this.mergePropertiesFiles(files, i18nPath, content, mergePathMatch[1]);
38
- }
39
- if (copyPathMatch) {
40
- files.set(path.join(i18nTargetFolder, filename), content);
41
- }
42
- }
43
- else {
44
- files.set(filename, content);
45
- }
40
+ async execute(files, filename, appVariantContent) {
41
+ // merge/copy logic
42
+ // check if file matches with regex in merge/copy
43
+ const mergePathMatch = this.mergePaths.map(path => filename.match(path)).find(match => match);
44
+ const copyPathMatch = this.copyPaths.map(path => filename.match(path)).find(match => match);
45
+ if (mergePathMatch) {
46
+ this.mergePropertiesFiles(files, this.i18nPath, appVariantContent, mergePathMatch[1]);
47
+ }
48
+ if (copyPathMatch) {
49
+ files.set(path.join(this.prefix, filename), appVariantContent);
46
50
  }
47
- return files;
48
51
  }
49
52
  /**
50
53
  * Filters out specific lines from the given string.
@@ -53,7 +56,7 @@ export default class FileMerger {
53
56
  * - ABAP_TRANSLATION
54
57
  * - SAPUI5 TRANSLATION-KEY
55
58
  */
56
- static filterTranslationMetaLines(content) {
59
+ filterTranslationMetaLines(content) {
57
60
  const lines = content.split('\n');
58
61
  const filtered = lines.filter(line => !/^# __ldi\.translation\.uuid\s*=/.test(line) &&
59
62
  !line.startsWith("# ABAP_TRANSLATION") &&
@@ -68,7 +71,7 @@ export default class FileMerger {
68
71
  * app variant Id as prefix => If we filter on them we do not need to remove
69
72
  * existing overwritten keys (as there should be none)
70
73
  */
71
- static mergePropertiesFiles(files, i18nPath, appVariantFileContent, language = "") {
74
+ mergePropertiesFiles(files, i18nPath, appVariantFileContent, language = "") {
72
75
  const baseAppI18nPath = i18nPath + language + ".properties";
73
76
  const baseAppFileContent = files.get(baseAppI18nPath);
74
77
  const filteredBaseContent = baseAppFileContent ? this.filterTranslationMetaLines(baseAppFileContent) : "";
@@ -78,4 +81,4 @@ export default class FileMerger {
78
81
  files.set(baseAppI18nPath, content);
79
82
  }
80
83
  }
81
- //# sourceMappingURL=i18nMerger.js.map
84
+ //# sourceMappingURL=i18nPropertiesMergeCommand.js.map
@@ -0,0 +1,7 @@
1
+ import { ManifestUpdateCommand } from "./command.js";
2
+ export default class SetAppVariantIdCommand extends ManifestUpdateCommand {
3
+ private appVariantId;
4
+ constructor(appVariantId: string);
5
+ accept: (filename: string) => filename is "manifest.json";
6
+ execute(manifest: any): Promise<void>;
7
+ }