@ui5/task-adaptation 1.4.3 → 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.
- package/CHANGELOG.md +6 -2
- package/README.md +16 -12
- package/dist/annotationManager.d.ts +1 -1
- package/dist/annotationManager.js +5 -8
- package/dist/annotations/serviceRequestor.js +3 -15
- package/dist/appVariantManager.d.ts +16 -11
- package/dist/appVariantManager.js +56 -83
- package/dist/baseAppManager.d.ts +16 -16
- package/dist/baseAppManager.js +57 -80
- package/dist/bundle.js +58 -42
- package/dist/cache/cacheHolder.d.ts +18 -0
- package/dist/cache/cacheHolder.js +80 -0
- package/dist/i18nManager.js +11 -9
- package/dist/index.js +34 -9
- package/dist/model/appVariantIdHierarchyItem.d.ts +5 -0
- package/dist/model/appVariantIdHierarchyItem.js +2 -0
- package/dist/model/language.d.ts +3 -3
- package/dist/model/language.js +11 -4
- package/dist/model/types.d.ts +2 -0
- package/dist/processors/abapProcessor.d.ts +5 -5
- package/dist/processors/abapProcessor.js +19 -7
- package/dist/processors/cfProcessor.d.ts +4 -4
- package/dist/processors/cfProcessor.js +28 -12
- package/dist/processors/processor.d.ts +4 -2
- package/dist/processors/processor.js +2 -4
- package/dist/repositories/abapRepoManager.d.ts +3 -1
- package/dist/repositories/abapRepoManager.js +24 -5
- package/dist/util/cfUtil.js +1 -1
- package/dist/util/commonUtil.d.ts +4 -2
- package/dist/util/commonUtil.js +105 -32
- package/dist/util/filesUtil.d.ts +17 -0
- package/dist/util/filesUtil.js +49 -0
- package/dist/util/i18nMerger.d.ts +15 -20
- package/dist/util/i18nMerger.js +46 -64
- package/dist/util/renamingHandlers/manifestHandler.d.ts +6 -0
- package/dist/util/renamingHandlers/manifestHandler.js +20 -0
- package/dist/util/renamingHandlers/renamingHandler.d.ts +4 -0
- package/dist/util/renamingHandlers/renamingHandler.js +2 -0
- package/dist/util/resourceUtil.d.ts +3 -1
- package/dist/util/resourceUtil.js +15 -2
- package/eslint.config.js +2 -5
- package/package.json +18 -12
- package/scripts/test-integration-prep.sh +4 -0
- package/types/ui5.d.ts +10 -0
- package/dist/cache/annotationsCacheManager.d.ts +0 -8
- package/dist/cache/annotationsCacheManager.js +0 -16
- package/dist/cache/baseAppFilesCacheManager.d.ts +0 -6
- package/dist/cache/baseAppFilesCacheManager.js +0 -12
- package/dist/cache/cacheManager.d.ts +0 -16
- package/dist/cache/cacheManager.js +0 -65
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default class ManifestHandler {
|
|
2
|
+
appVariantIdHierarchy = [];
|
|
3
|
+
before(files) {
|
|
4
|
+
const manifest = files.get("manifest.json");
|
|
5
|
+
if (manifest) {
|
|
6
|
+
const manifestJson = JSON.parse(manifest);
|
|
7
|
+
this.appVariantIdHierarchy = manifestJson["sap.ui5"].appVariantIdHierarchy;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
after(files) {
|
|
11
|
+
const manifest = files.get("manifest.json");
|
|
12
|
+
if (manifest) {
|
|
13
|
+
const manifestJson = JSON.parse(manifest);
|
|
14
|
+
manifestJson["sap.ui5"].appVariantIdHierarchy = this.appVariantIdHierarchy;
|
|
15
|
+
files.set("manifest.json", JSON.stringify(manifestJson));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=manifestHandler.js.map
|
|
@@ -3,9 +3,11 @@ export default class ResourceUtil {
|
|
|
3
3
|
static relativeToRoot(resourcePath: string, projectNamespace?: string): string;
|
|
4
4
|
static getResourcePath(projectNamespace?: string, ...paths: string[]): string;
|
|
5
5
|
static write(dir: string, files: Map<string, string>): Promise<void[]>;
|
|
6
|
-
static
|
|
6
|
+
private static _read;
|
|
7
|
+
static read(folder: string): Map<string, string>;
|
|
7
8
|
static getString(resource: any): Promise<string>;
|
|
8
9
|
static getJson(resource: any): Promise<any>;
|
|
9
10
|
static setString(resource: any, str: string): void;
|
|
10
11
|
static createResource(filename: string, projectNamespace: string, content: string): any;
|
|
12
|
+
static toFileMap(resources: ReadonlyArray<Resource>, projectNamespace: string): Promise<Map<string, string>>;
|
|
11
13
|
}
|
|
@@ -29,7 +29,7 @@ export default class ResourceUtil {
|
|
|
29
29
|
});
|
|
30
30
|
return Promise.all(promises);
|
|
31
31
|
}
|
|
32
|
-
static
|
|
32
|
+
static _read(rootFolder, folder, files, exclude = []) {
|
|
33
33
|
const entries = fs.readdirSync(folder);
|
|
34
34
|
for (let entry of entries) {
|
|
35
35
|
const entryPath = path.join(folder, entry);
|
|
@@ -39,10 +39,15 @@ export default class ResourceUtil {
|
|
|
39
39
|
files.set(normalized, fs.readFileSync(entryPath, { encoding: "utf-8" }));
|
|
40
40
|
}
|
|
41
41
|
else if (stats.isDirectory()) {
|
|
42
|
-
this.
|
|
42
|
+
this._read(rootFolder, entryPath, files, exclude);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
+
static read(folder) {
|
|
47
|
+
const files = new Map();
|
|
48
|
+
this._read(folder, folder, files);
|
|
49
|
+
return files;
|
|
50
|
+
}
|
|
46
51
|
static getString(resource) {
|
|
47
52
|
return resource.getBuffer().then((buffer) => buffer.toString(UTF8));
|
|
48
53
|
}
|
|
@@ -58,5 +63,13 @@ export default class ResourceUtil {
|
|
|
58
63
|
string: content
|
|
59
64
|
});
|
|
60
65
|
}
|
|
66
|
+
static async toFileMap(resources, projectNamespace) {
|
|
67
|
+
const files = new Map();
|
|
68
|
+
const rootFolderLength = ResourceUtil.getRootFolder(projectNamespace).length;
|
|
69
|
+
for (const resource of resources) {
|
|
70
|
+
files.set(resource.getPath().substring(rootFolderLength + 1), await ResourceUtil.getString(resource));
|
|
71
|
+
}
|
|
72
|
+
return files;
|
|
73
|
+
}
|
|
61
74
|
}
|
|
62
75
|
//# sourceMappingURL=resourceUtil.js.map
|
package/eslint.config.js
CHANGED
|
@@ -11,7 +11,7 @@ export default tseslint.config(
|
|
|
11
11
|
parserOptions: {
|
|
12
12
|
project: [
|
|
13
13
|
"./tsconfig.json",
|
|
14
|
-
"./test/tsconfig.json",
|
|
14
|
+
"./test/lib/tsconfig.json",
|
|
15
15
|
"./scripts/tsconfig.json"
|
|
16
16
|
],
|
|
17
17
|
tsconfigRootDir: import.meta.dirname,
|
|
@@ -64,8 +64,5 @@ export default tseslint.config(
|
|
|
64
64
|
rules: {
|
|
65
65
|
"@typescript-eslint/no-unused-expressions": "off"
|
|
66
66
|
},
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
ignores: ["test/resources/**"]
|
|
70
67
|
}
|
|
71
|
-
);
|
|
68
|
+
);
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui5/task-adaptation",
|
|
3
|
-
"version": "1.
|
|
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": "eslint ./src ./test",
|
|
9
|
-
"dev": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx --loader=esmock 'test/**/*.spec.ts'",
|
|
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'",
|
|
10
12
|
"coverage": "c8 npm run dev",
|
|
11
13
|
"preversion": "npm test",
|
|
12
14
|
"version": "git-chglog --next-tag v$npm_package_version -o CHANGELOG.md && git add CHANGELOG.md",
|
|
@@ -14,7 +16,8 @@
|
|
|
14
16
|
"release-note": "git-chglog -c .chglog/release-config.yml v$npm_package_version",
|
|
15
17
|
"rollup": "tsx scripts/rollup.ts",
|
|
16
18
|
"build": "npm run rollup && tsc -p ./",
|
|
17
|
-
"download-metadata": "tsx scripts/metadataDownloadHelper.ts"
|
|
19
|
+
"download-metadata": "tsx scripts/metadataDownloadHelper.ts",
|
|
20
|
+
"integration-setup": "scripts/test-integration-prep.sh"
|
|
18
21
|
},
|
|
19
22
|
"repository": {
|
|
20
23
|
"type": "git",
|
|
@@ -43,9 +46,10 @@
|
|
|
43
46
|
"axios": "^1.8.3",
|
|
44
47
|
"crc": "^4.3.2",
|
|
45
48
|
"dotenv": "^16.0.3",
|
|
49
|
+
"filenamify": "^6.0.0",
|
|
46
50
|
"jsdom": "^23.0.1",
|
|
47
|
-
"meriyah": "^6.0.3",
|
|
48
51
|
"temp-dir": "^2.0.0",
|
|
52
|
+
"transliteration": "^2.3.5",
|
|
49
53
|
"xml-js": "^1.6.11"
|
|
50
54
|
},
|
|
51
55
|
"devDependencies": {
|
|
@@ -60,19 +64,19 @@
|
|
|
60
64
|
"@types/mocha": "^9.1.0",
|
|
61
65
|
"@types/semver": "^7.3.8",
|
|
62
66
|
"@types/sinon": "^10.0.16",
|
|
67
|
+
"@ui5/builder": "^4.0.3",
|
|
63
68
|
"@ui5/project": "^4.0.3",
|
|
64
69
|
"amdextract": "^3.0.0",
|
|
65
70
|
"builtin-modules": "^3.2.0",
|
|
66
71
|
"c8": "^10.1.3",
|
|
67
72
|
"chai": "^4.3.4",
|
|
68
73
|
"chai-as-promised": "^7.1.1",
|
|
69
|
-
"chalk": "^4.1.2",
|
|
70
74
|
"eslint": "^9.22.0",
|
|
71
75
|
"eslint-plugin-import": "^2.31.0",
|
|
72
76
|
"esmock": "^2.6.3",
|
|
73
77
|
"glob": "^10.3.10",
|
|
74
78
|
"js-yaml": "^4.1.0",
|
|
75
|
-
"
|
|
79
|
+
"meriyah": "^6.0.3",
|
|
76
80
|
"minimatch": "^9.0.3",
|
|
77
81
|
"mocha": "^11.1.0",
|
|
78
82
|
"mock-require": "^3.0.3",
|
|
@@ -84,9 +88,6 @@
|
|
|
84
88
|
"typescript": "^5.4.2",
|
|
85
89
|
"typescript-eslint": "^8.26.1"
|
|
86
90
|
},
|
|
87
|
-
"optionalDependencies": {
|
|
88
|
-
"@rollup/rollup-linux-x64-gnu": "4.39.0"
|
|
89
|
-
},
|
|
90
91
|
"c8": {
|
|
91
92
|
"src": "./src",
|
|
92
93
|
"all": true,
|
|
@@ -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
|
}
|
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,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
|