@ui5/task-adaptation 1.4.2 → 1.5.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/README.md +16 -12
  3. package/REUSE.toml +10 -0
  4. package/dist/annotationManager.d.ts +1 -1
  5. package/dist/annotationManager.js +5 -8
  6. package/dist/annotations/dataSource/dataSource.js +0 -1
  7. package/dist/annotations/serviceRequestor.js +3 -15
  8. package/dist/appVariantManager.d.ts +16 -11
  9. package/dist/appVariantManager.js +56 -83
  10. package/dist/baseAppManager.d.ts +16 -16
  11. package/dist/baseAppManager.js +58 -81
  12. package/dist/bundle.d.ts +2 -3
  13. package/dist/bundle.js +3834 -3490
  14. package/dist/cache/cacheHolder.d.ts +18 -0
  15. package/dist/cache/cacheHolder.js +80 -0
  16. package/dist/i18nManager.js +11 -9
  17. package/dist/index.js +34 -9
  18. package/dist/model/appVariantIdHierarchyItem.d.ts +5 -0
  19. package/dist/model/appVariantIdHierarchyItem.js +2 -0
  20. package/dist/model/configuration.d.ts +2 -2
  21. package/dist/model/language.d.ts +3 -3
  22. package/dist/model/language.js +11 -4
  23. package/dist/model/types.d.ts +3 -1
  24. package/dist/processors/abapProcessor.d.ts +5 -5
  25. package/dist/processors/abapProcessor.js +19 -7
  26. package/dist/processors/cfProcessor.d.ts +4 -4
  27. package/dist/processors/cfProcessor.js +29 -13
  28. package/dist/processors/processor.d.ts +4 -2
  29. package/dist/processors/processor.js +3 -5
  30. package/dist/repositories/abapRepoManager.d.ts +3 -1
  31. package/dist/repositories/abapRepoManager.js +24 -5
  32. package/dist/repositories/html5RepoManager.js +3 -2
  33. package/dist/util/cfUtil.d.ts +1 -0
  34. package/dist/util/cfUtil.js +27 -23
  35. package/dist/util/commonUtil.d.ts +5 -3
  36. package/dist/util/commonUtil.js +104 -31
  37. package/dist/util/filesUtil.d.ts +17 -0
  38. package/dist/util/filesUtil.js +49 -0
  39. package/dist/util/i18nMerger.d.ts +15 -20
  40. package/dist/util/i18nMerger.js +46 -64
  41. package/dist/util/renamingHandlers/manifestHandler.d.ts +6 -0
  42. package/dist/util/renamingHandlers/manifestHandler.js +20 -0
  43. package/dist/util/renamingHandlers/renamingHandler.d.ts +4 -0
  44. package/dist/util/renamingHandlers/renamingHandler.js +2 -0
  45. package/dist/util/requestUtil.d.ts +2 -1
  46. package/dist/util/resourceUtil.d.ts +3 -1
  47. package/dist/util/resourceUtil.js +15 -2
  48. package/eslint.config.js +20 -4
  49. package/package.json +28 -22
  50. package/scripts/rollup/bundle.d.ts +2 -3
  51. package/scripts/rollup/bundleDefinition.js +2 -2
  52. package/scripts/rollup/overrides/sap/ui/fl/Utils.js +13 -0
  53. package/scripts/rollup/overrides/sap/ui/fl/apply/_internal/changes/FlexCustomData.js +13 -0
  54. package/scripts/rollup/overrides/sap/ui/fl/apply/_internal/flexObjects/AnnotationChange.js +11 -0
  55. package/scripts/rollup/overrides/sap/ui/fl/apply/_internal/flexObjects/AppDescriptorChange.js +68 -0
  56. package/scripts/rollup/overrides/sap/ui/fl/apply/_internal/flexObjects/VariantChange.js +11 -0
  57. package/scripts/rollup/overrides/sap/ui/fl/apply/_internal/flexObjects/VariantManagementChange.js +11 -0
  58. package/scripts/rollup/overrides/sap/ui/fl/apply/_internal/flexState/controlVariants/VariantManagementState.js +13 -0
  59. package/scripts/rollup/overrides/sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerRegistration.js +13 -0
  60. package/scripts/rollup/overrides/sap/ui/fl/initial/_internal/changeHandlers/ChangeHandlerStorage.js +14 -0
  61. package/scripts/rollup/project/ui5.yaml +1 -1
  62. package/scripts/test-integration-prep.sh +4 -0
  63. package/types/ui5.d.ts +10 -0
  64. package/dist/cache/annotationsCacheManager.d.ts +0 -8
  65. package/dist/cache/annotationsCacheManager.js +0 -16
  66. package/dist/cache/baseAppFilesCacheManager.d.ts +0 -6
  67. package/dist/cache/baseAppFilesCacheManager.js +0 -12
  68. package/dist/cache/cacheManager.d.ts +0 -16
  69. package/dist/cache/cacheManager.js +0 -65
  70. package/scripts/rollup/overrides/sap/ui/fl/Change.js +0 -74
package/eslint.config.js CHANGED
@@ -1,5 +1,3 @@
1
- // @ts-check
2
-
3
1
  import * as eslintimport from "eslint-plugin-import";
4
2
 
5
3
  import eslint from "@eslint/js";
@@ -11,7 +9,11 @@ export default tseslint.config(
11
9
  {
12
10
  languageOptions: {
13
11
  parserOptions: {
14
- project: true,
12
+ project: [
13
+ "./tsconfig.json",
14
+ "./test/lib/tsconfig.json",
15
+ "./scripts/tsconfig.json"
16
+ ],
15
17
  tsconfigRootDir: import.meta.dirname,
16
18
  },
17
19
  },
@@ -46,7 +48,21 @@ export default tseslint.config(
46
48
  {
47
49
  "js": "always"
48
50
  }
51
+ ],
52
+ "@typescript-eslint/no-unused-vars": [
53
+ "warn", // or "error"
54
+ {
55
+ "argsIgnorePattern": "^_",
56
+ "varsIgnorePattern": "^_",
57
+ "caughtErrorsIgnorePattern": "^_"
58
+ }
49
59
  ]
50
60
  }
61
+ },
62
+ {
63
+ files: ["test/**/*.spec.ts"],
64
+ rules: {
65
+ "@typescript-eslint/no-unused-expressions": "off"
66
+ },
51
67
  }
52
- );
68
+ );
package/package.json CHANGED
@@ -1,21 +1,23 @@
1
1
  {
2
2
  "name": "@ui5/task-adaptation",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "description": "Custom task for ui5-builder which allows building UI5 Flexibility Adaptation Projects for SAP BTP, Cloud Foundry environment",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "npm run lint && npm run build && npm run coverage",
8
- "lint": "npx eslint ./src",
9
- "dev": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx --loader=esmock 'test/**/*.spec.ts'",
10
- "perf": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx --loader=esmock 'test/**/*.perf.ts'",
11
- "coverage": "npx c8 npm run dev",
8
+ "lint": "eslint ./src ./test/lib",
9
+ "dev": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx --loader=esmock 'test/lib/**/*.spec.ts'",
10
+ "perf": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx --loader=esmock 'test/lib/**/*.perf.ts'",
11
+ "integration": "UI5_LOG_LVL=error mocha --reporter-option maxDiffSize=0 --no-timeouts --no-warnings --import=tsx --loader=esmock 'test/lib/**/*.int.ts'",
12
+ "coverage": "c8 npm run dev",
12
13
  "preversion": "npm test",
13
14
  "version": "git-chglog --next-tag v$npm_package_version -o CHANGELOG.md && git add CHANGELOG.md",
14
15
  "prepublishOnly": "git push --follow-tags",
15
16
  "release-note": "git-chglog -c .chglog/release-config.yml v$npm_package_version",
16
17
  "rollup": "tsx scripts/rollup.ts",
17
18
  "build": "npm run rollup && tsc -p ./",
18
- "download-metadata": "tsx scripts/metadataDownloadHelper.ts"
19
+ "download-metadata": "tsx scripts/metadataDownloadHelper.ts",
20
+ "integration-setup": "scripts/test-integration-prep.sh"
19
21
  },
20
22
  "repository": {
21
23
  "type": "git",
@@ -34,25 +36,25 @@
34
36
  "license": "Apache-2.0",
35
37
  "dependencies": {
36
38
  "@sap-ux/axios-extension": "^1.16.6",
37
- "@sap-ux/btp-utils": "^0.15.2",
39
+ "@sap-ux/btp-utils": "^1.0.2",
38
40
  "@sap-ux/store": "^0.9.1",
39
41
  "@sap-ux/system-access": "^0.5.11",
40
42
  "@sap/cf-tools": "^3.2.0",
41
43
  "@ui5/fs": "^4.0.1",
42
44
  "@ui5/logger": "^4.0.1",
43
45
  "adm-zip": "^0.5.5",
44
- "axios": "^1.7.9",
46
+ "axios": "^1.8.3",
45
47
  "crc": "^4.3.2",
46
48
  "dotenv": "^16.0.3",
49
+ "filenamify": "^6.0.0",
47
50
  "jsdom": "^23.0.1",
48
- "meriyah": "^6.0.3",
49
51
  "temp-dir": "^2.0.0",
52
+ "transliteration": "^2.3.5",
50
53
  "xml-js": "^1.6.11"
51
54
  },
52
55
  "devDependencies": {
53
56
  "@buxlabs/amd-to-es6": "^0.16.3",
54
- "@istanbuljs/nyc-config-typescript": "^1.0.1",
55
- "@rollup/plugin-node-resolve": "^15.2.3",
57
+ "@rollup/plugin-node-resolve": "^15.3.0",
56
58
  "@types/adm-zip": "^0.4.34",
57
59
  "@types/chai": "^4.2.21",
58
60
  "@types/chai-as-promised": "^7.1.4",
@@ -62,30 +64,29 @@
62
64
  "@types/mocha": "^9.1.0",
63
65
  "@types/semver": "^7.3.8",
64
66
  "@types/sinon": "^10.0.16",
67
+ "@ui5/builder": "^4.0.3",
65
68
  "@ui5/project": "^4.0.3",
66
69
  "amdextract": "^3.0.0",
67
70
  "builtin-modules": "^3.2.0",
68
- "c8": "^9.1.0",
71
+ "c8": "^10.1.3",
69
72
  "chai": "^4.3.4",
70
73
  "chai-as-promised": "^7.1.1",
71
- "chalk": "^4.1.2",
72
- "eslint": "^8.57.0",
73
- "eslint-plugin-import": "^2.29.1",
74
+ "eslint": "^9.22.0",
75
+ "eslint-plugin-import": "^2.31.0",
74
76
  "esmock": "^2.6.3",
75
77
  "glob": "^10.3.10",
76
78
  "js-yaml": "^4.1.0",
77
- "lodash": "^4.17.21",
79
+ "meriyah": "^6.0.3",
78
80
  "minimatch": "^9.0.3",
79
- "mocha": "^10.2.0",
81
+ "mocha": "^11.1.0",
80
82
  "mock-require": "^3.0.3",
81
- "nyc": "^15.1.0",
82
- "rollup": "^4.9.6",
83
+ "rollup": "^4.24.0",
83
84
  "semver": "^7.3.5",
84
85
  "sinon": "^18.0.1",
85
86
  "source-map-support": "^0.5.19",
86
87
  "tsx": "^4.7.1",
87
88
  "typescript": "^5.4.2",
88
- "typescript-eslint": "^7.2.0"
89
+ "typescript-eslint": "^8.26.1"
89
90
  },
90
91
  "c8": {
91
92
  "src": "./src",
@@ -110,7 +111,8 @@
110
111
  "*/**/*.d.ts",
111
112
  "src/annotations/comparator/diffCase.ts",
112
113
  "src/annotations/transformers/transformer.ts",
113
- "src/model/configuration.ts"
114
+ "src/model/configuration.ts",
115
+ "src/model/appVariantIdHierarchyItem.ts"
114
116
  ],
115
117
  "check-coverage": true,
116
118
  "statements": 85,
@@ -119,5 +121,9 @@
119
121
  "lines": 85
120
122
  },
121
123
  "types": "dist/index.d.ts",
122
- "type": "module"
124
+ "type": "module",
125
+ "optionalDependencies": {
126
+ "@rollup/rollup-linux-x64-gnu": "^4.28.1",
127
+ "@rollup/rollup-linux-x64-musl": "^4.28.1"
128
+ }
123
129
  }
@@ -1,13 +1,12 @@
1
1
  export declare const RegistrationBuild: () => void;
2
2
 
3
3
  export declare class Applier {
4
- static applyChanges(manifest: any, changes: Change[], strategy: any): Promise<void>;
4
+ static applyChanges(manifest: any, changes: AppDescriptorChange[], strategy: any): Promise<void>;
5
5
  }
6
6
 
7
- export declare class Change {
7
+ export declare class AppDescriptorChange {
8
8
  constructor(change: any);
9
9
  getLayer(): string;
10
- _oDefinition: any;
11
10
  }
12
11
 
13
12
  export declare class V2MetadataConverter {
@@ -1,7 +1,7 @@
1
1
  //Flex
2
+ import AppDescriptorChange from "sap/ui/fl/apply/_internal/flexObjects/AppDescriptorChange";
2
3
  import Applier from "sap/ui/fl/apply/_internal/changes/descriptor/Applier";
3
4
  import ApplyUtil from "sap/ui/fl/apply/_internal/changes/descriptor/ApplyUtil";
4
- import Change from "sap/ui/fl/Change";
5
5
  import RegistrationBuild from "sap/ui/fl/apply/_internal/changes/descriptor/RegistrationBuild";
6
6
  //OData
7
7
  import URI from "sap/ui/thirdparty/URI";
@@ -10,9 +10,9 @@ import V4MetadataConverter from "sap/ui/model/odata/v4/lib/_V4MetadataConverter"
10
10
 
11
11
  export {
12
12
  //Flex
13
+ AppDescriptorChange,
13
14
  Applier,
14
15
  ApplyUtil,
15
- Change,
16
16
  RegistrationBuild,
17
17
  //OData
18
18
  URI,
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2025 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+
7
+ sap.ui.define([
8
+ ], function (
9
+ ) {
10
+ return {
11
+ getChangeFromChangesMap: function () { }
12
+ };
13
+ });
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2025 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+
7
+ sap.ui.define([
8
+ ], function (
9
+ ) {
10
+ return {
11
+ hasChangeApplyFinishedCustomData: function () { }
12
+ };
13
+ });
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2020 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+
7
+ sap.ui.define([
8
+ ], function (
9
+ ) {
10
+ return function () {};
11
+ }, true);
@@ -0,0 +1,68 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2020 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+
7
+ sap.ui.define([
8
+ ], function (
9
+ ) {
10
+ "use strict";
11
+
12
+ /**
13
+ * Flexibility change class. Stores change content and related information.
14
+ *
15
+ * @param {object} oFile - File content and admin data
16
+ *
17
+ * @class sap.ui.fl.Change
18
+ * @private
19
+ * @ui5-restricted
20
+ * @experimental Since 1.25.0
21
+ */
22
+ var AppDescriptorChange = function (content) {
23
+ this.content = content;
24
+ };
25
+
26
+ /**
27
+ * Returns the change type.
28
+ *
29
+ * @returns {String} Change type of the file, for example <code>LabelChange</code>
30
+ * @public
31
+ */
32
+ AppDescriptorChange.prototype.getChangeType = function () {
33
+ return this.content?.flexObjectMetadata?.changeType || this.content?.changeType;
34
+ };
35
+
36
+ /**
37
+ * Gets the layer type for the change.
38
+ * @returns {string} Layer of the change file
39
+ *
40
+ * @public
41
+ */
42
+ AppDescriptorChange.prototype.getLayer = function () {
43
+ return this.content.layer;
44
+ };
45
+
46
+ /**
47
+ * Returns the content section of the change.
48
+ * @returns {string} Content of the change file. The content structure can be any JSON.
49
+ *
50
+ * @public
51
+ */
52
+ AppDescriptorChange.prototype.getContent = function () {
53
+ return this.content.content;
54
+ };
55
+
56
+ /**
57
+ * Returns all texts.
58
+ *
59
+ * @returns {object} All texts
60
+ *
61
+ * @function
62
+ */
63
+ AppDescriptorChange.prototype.getTexts = function () {
64
+ return this.content.texts;
65
+ };
66
+
67
+ return AppDescriptorChange;
68
+ }, true);
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2020 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+
7
+ sap.ui.define([
8
+ ], function (
9
+ ) {
10
+ return function () {};
11
+ }, true);
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2020 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+
7
+ sap.ui.define([
8
+ ], function (
9
+ ) {
10
+ return function () {};
11
+ }, true);
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2025 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+
7
+ sap.ui.define([
8
+ ], function (
9
+ ) {
10
+ return {
11
+ getChangeInformationProvider: function () { }
12
+ };
13
+ });
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2025 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+
7
+ sap.ui.define([
8
+ ], function (
9
+ ) {
10
+ return {
11
+ waitForChangeHandlerRegistration: function () { }
12
+ };
13
+ });
@@ -0,0 +1,14 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2025 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+
7
+ sap.ui.define([
8
+ ], function (
9
+ ) {
10
+ return {
11
+ getAnnotationChangeHandler: function () { },
12
+ getChangeHandler: function () { }
13
+ };
14
+ });
@@ -6,7 +6,7 @@ metadata:
6
6
  allowSapInternal: true
7
7
  framework:
8
8
  name: SAPUI5
9
- version: 1.131.0
9
+ version: 0.0.0
10
10
  libraries:
11
11
  - name: sap.ui.fl
12
12
  - name: sap.suite.ui.generic.template
@@ -0,0 +1,4 @@
1
+ for d in test/fixtures/*/ ; do
2
+ echo "$d"
3
+ npm --prefix $d i
4
+ done
package/types/ui5.d.ts CHANGED
@@ -18,6 +18,11 @@ declare class Resource {
18
18
  setString(string: string): void;
19
19
  }
20
20
 
21
+ declare interface IWorkspace {
22
+ write(resource: Resource): Promise<void>;
23
+ byGlob(pattern: string): Promise<Resource[]>;
24
+ }
25
+
21
26
  declare module "@ui5/fs/Resource" {
22
27
  export function getPath(): string;
23
28
  export function clone(): Resource;
@@ -39,6 +44,11 @@ declare module "@ui5/project/build/helpers/BuildContext" {
39
44
 
40
45
  declare module "@ui5/project/build/helpers/TaskUtil" {
41
46
  export default class TaskUtil {
47
+ STANDARD_TAGS: any;
48
+ setTag(resource: Resource, OmitFromBuildResult: any, omit: boolean);
42
49
  constructor(options: any);
43
50
  }
44
51
  }
52
+
53
+ declare module "@ui5/builder/internal/taskRepository" {
54
+ }
@@ -1,8 +0,0 @@
1
- import CacheManager from "./cacheManager.js";
2
- import { IConfiguration } from "../model/types.js";
3
- export default class AnnotationsCacheManager extends CacheManager {
4
- private tempSubFolder;
5
- constructor(configuration: IConfiguration, tempSubFolder: string);
6
- protected getTempId(): string;
7
- getMetadataFilename(): string;
8
- }
@@ -1,16 +0,0 @@
1
- import CacheManager from "./cacheManager.js";
2
- export default class AnnotationsCacheManager extends CacheManager {
3
- tempSubFolder;
4
- constructor(configuration, tempSubFolder) {
5
- super(configuration);
6
- this.tempSubFolder = tempSubFolder;
7
- }
8
- getTempId() {
9
- const { destination, appName } = this.configuration;
10
- return super.normalizeId(`ui5-${destination}-${appName}-${this.tempSubFolder}`);
11
- }
12
- getMetadataFilename() {
13
- return "annotationsmetadata.json";
14
- }
15
- }
16
- //# sourceMappingURL=annotationsCacheManager.js.map
@@ -1,6 +0,0 @@
1
- import CacheManager from "./cacheManager.js";
2
- export default class BaseAppFilesCacheManager extends CacheManager {
3
- static METADATA_FILENAME: string;
4
- protected getTempId(): string;
5
- getMetadataFilename(): string;
6
- }
@@ -1,12 +0,0 @@
1
- import CacheManager from "./cacheManager.js";
2
- export default class BaseAppFilesCacheManager extends CacheManager {
3
- static METADATA_FILENAME = "html5metadata.json";
4
- getTempId() {
5
- const { appHostId, appName, appVersion } = this.configuration;
6
- return super.normalizeId(`ui5-${appHostId}-${appName}-${appVersion}`);
7
- }
8
- getMetadataFilename() {
9
- return BaseAppFilesCacheManager.METADATA_FILENAME;
10
- }
11
- }
12
- //# sourceMappingURL=baseAppFilesCacheManager.js.map
@@ -1,16 +0,0 @@
1
- import { IConfiguration, IMetadata } from "../model/types.js";
2
- export default abstract class CacheManager {
3
- protected configuration: IConfiguration;
4
- constructor(configuration: IConfiguration);
5
- protected abstract getMetadataFilename(): string;
6
- protected abstract getTempId(): string;
7
- protected getTempFolder(): string;
8
- getFiles(fetchMetadata: () => Promise<IMetadata>, fetchFiles: () => Promise<Map<string, string>>): Promise<Map<string, string>>;
9
- isMetadataSame(tempMetadata: IMetadata, metadata: IMetadata): boolean;
10
- readTempMetadata(): any;
11
- writeTemp(files: Map<string, string>, metadata: any): Promise<void[]>;
12
- readTemp(): Promise<Map<string, string>>;
13
- deleteTemp(): void;
14
- protected normalizeId(id: string): string;
15
- private getFilesToCache;
16
- }
@@ -1,65 +0,0 @@
1
- import * as fs from "fs";
2
- import * as path from "path";
3
- import ResourceUtil from "../util/resourceUtil.js";
4
- import tempFolder from "temp-dir";
5
- export default class CacheManager {
6
- configuration;
7
- constructor(configuration) {
8
- this.configuration = configuration;
9
- }
10
- getTempFolder() {
11
- return path.join(tempFolder, this.getTempId());
12
- }
13
- async getFiles(fetchMetadata, fetchFiles) {
14
- const tempMetadata = this.readTempMetadata();
15
- const metadata = await fetchMetadata();
16
- if (this.isMetadataSame(tempMetadata, metadata)) {
17
- return this.readTemp();
18
- }
19
- else {
20
- const files = await fetchFiles();
21
- if (files?.size > 0) {
22
- await this.writeTemp(files, metadata);
23
- }
24
- return files;
25
- }
26
- }
27
- isMetadataSame(tempMetadata, metadata) {
28
- // TODO: Implement correct metadata comparision.
29
- return tempMetadata && metadata && tempMetadata.changedOn === metadata.changedOn;
30
- }
31
- readTempMetadata() {
32
- const tempFolder = this.getTempFolder();
33
- const filename = this.getMetadataFilename();
34
- const metadataPath = path.resolve(tempFolder, filename);
35
- if (fs.existsSync(metadataPath)) {
36
- return JSON.parse(fs.readFileSync(metadataPath, { encoding: "utf-8" }));
37
- }
38
- }
39
- writeTemp(files, metadata) {
40
- this.deleteTemp();
41
- const filesToCache = this.getFilesToCache(files, metadata);
42
- return ResourceUtil.write(this.getTempFolder(), filesToCache);
43
- }
44
- async readTemp() {
45
- const files = new Map();
46
- const tempFolder = this.getTempFolder();
47
- if (fs.existsSync(tempFolder)) {
48
- ResourceUtil.read(tempFolder, tempFolder, files, [this.getMetadataFilename()]);
49
- }
50
- return files;
51
- }
52
- deleteTemp() {
53
- fs.rmSync(this.getTempFolder(), { recursive: true, force: true });
54
- }
55
- normalizeId(id) {
56
- return id.replace(/\/\\/g, "_");
57
- }
58
- getFilesToCache(files, metadata) {
59
- const filename = this.getMetadataFilename();
60
- const filesClone = new Map([...files]);
61
- filesClone.set(filename, JSON.stringify(metadata));
62
- return filesClone;
63
- }
64
- }
65
- //# sourceMappingURL=cacheManager.js.map
@@ -1,74 +0,0 @@
1
- /*!
2
- * OpenUI5
3
- * (c) Copyright 2009-2020 SAP SE or an SAP affiliate company.
4
- * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
- */
6
-
7
- sap.ui.define([
8
-
9
- ], function (
10
-
11
- ) {
12
- "use strict";
13
-
14
- /**
15
- * Flexibility change class. Stores change content and related information.
16
- *
17
- * @param {object} oFile - File content and admin data
18
- *
19
- * @class sap.ui.fl.Change
20
- * @private
21
- * @ui5-restricted
22
- * @experimental Since 1.25.0
23
- */
24
- var Change = function (oFile) {
25
- this._oDefinition = oFile;
26
- };
27
-
28
- /**
29
- * Returns the change type.
30
- *
31
- * @returns {String} Change type of the file, for example <code>LabelChange</code>
32
- * @public
33
- */
34
- Change.prototype.getChangeType = function () {
35
- if (this._oDefinition) {
36
- return this._oDefinition.flexObjectMetadata
37
- ? this._oDefinition.flexObjectMetadata.changeType
38
- : this._oDefinition.changeType
39
- }
40
- };
41
-
42
- /**
43
- * Gets the layer type for the change.
44
- * @returns {string} Layer of the change file
45
- *
46
- * @public
47
- */
48
- Change.prototype.getLayer = function () {
49
- return this._oDefinition.layer;
50
- };
51
-
52
- /**
53
- * Returns the content section of the change.
54
- * @returns {string} Content of the change file. The content structure can be any JSON.
55
- *
56
- * @public
57
- */
58
- Change.prototype.getContent = function () {
59
- return this._oDefinition.content;
60
- };
61
-
62
- /**
63
- * Returns all texts.
64
- *
65
- * @returns {object} All texts
66
- *
67
- * @function
68
- */
69
- Change.prototype.getTexts = function () {
70
- return this._oDefinition.texts;
71
- };
72
-
73
- return Change;
74
- }, true);