@ui5/task-adaptation 1.5.2 → 1.6.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/.hyperspace/pull_request_bot.json +19 -0
- package/CHANGELOG.md +11 -6
- package/dist/appVariantManager.js +1 -1
- package/dist/baseAppManager.js +3 -3
- package/dist/buildStrategy.d.ts +0 -3
- package/dist/buildStrategy.js +0 -7
- package/dist/bundle.d.ts +4 -3
- package/dist/bundle.js +3650 -3595
- package/dist/cache/cacheHolder.d.ts +1 -1
- package/dist/cache/cacheHolder.js +8 -6
- package/dist/index.js +5 -1
- package/dist/model/authenticationError.d.ts +3 -0
- package/dist/model/authenticationError.js +8 -0
- package/dist/model/types.d.ts +12 -0
- package/dist/previewManager.d.ts +13 -0
- package/dist/previewManager.js +142 -0
- package/dist/processors/abapProcessor.d.ts +1 -0
- package/dist/processors/abapProcessor.js +3 -0
- package/dist/processors/cfProcessor.d.ts +2 -1
- package/dist/processors/cfProcessor.js +11 -1
- package/dist/processors/processor.d.ts +2 -1
- package/dist/repositories/html5RepoManager.d.ts +3 -2
- package/dist/repositories/html5RepoManager.js +18 -5
- package/dist/util/cfUtil.d.ts +8 -1
- package/dist/util/cfUtil.js +16 -8
- package/dist/util/movingHandler/changeFileMoveHandler.d.ts +8 -0
- package/dist/util/movingHandler/changeFileMoveHandler.js +77 -0
- package/dist/util/resourceUtil.d.ts +11 -3
- package/dist/util/resourceUtil.js +83 -18
- package/eslint.config.js +4 -3
- package/package.json +19 -20
- package/rollup/amdToEsm.ts +22 -0
- package/rollup/bundle.d.ts +25 -0
- package/rollup/bundleDefinition.js +19 -0
- package/rollup/bundler.ts +35 -0
- package/rollup/overrides/sap/base/config.js +59 -0
- package/rollup/overrides/sap/ui/fl/apply/_internal/flexObjects/AppDescriptorChange.js +68 -0
- package/rollup/overrides/sap/ui/performance/Measurement.js +4 -0
- package/rollup/project/package.json +4 -0
- package/rollup/project/ui5.yaml +13 -0
- package/rollup/project/webapp/manifest.json +5 -0
- package/rollup/rollup.ts +133 -0
- package/rollup/ui5Resolve.ts +145 -0
- package/scripts/publish.ts +256 -0
- package/scripts/test-integration-prep.sh +4 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
1
|
import * as resourceFactory from "@ui5/fs/resourceFactory";
|
|
3
2
|
import { posix as path } from "path";
|
|
3
|
+
import * as fs from "fs/promises";
|
|
4
4
|
const UTF8 = "utf8";
|
|
5
5
|
export default class ResourceUtil {
|
|
6
6
|
static getRootFolder(projectNamespace) {
|
|
@@ -17,6 +17,14 @@ export default class ResourceUtil {
|
|
|
17
17
|
static getResourcePath(projectNamespace, ...paths) {
|
|
18
18
|
return path.join(this.getRootFolder(projectNamespace), ...paths);
|
|
19
19
|
}
|
|
20
|
+
/*
|
|
21
|
+
* Write files to the specified folder.
|
|
22
|
+
* NOTE: to write in project folder (folder where 'webapp',
|
|
23
|
+
* 'package.json', 'ui5.yaml' located), use writeInProject method.
|
|
24
|
+
* @param dir The directory to write files to.
|
|
25
|
+
* @param files A Map of file paths and their contents.
|
|
26
|
+
* @returns A promise that resolves when all files have been written.
|
|
27
|
+
*/
|
|
20
28
|
static write(dir, files) {
|
|
21
29
|
const fsTarget = resourceFactory.createAdapter({
|
|
22
30
|
fsBasePath: dir,
|
|
@@ -29,25 +37,65 @@ export default class ResourceUtil {
|
|
|
29
37
|
});
|
|
30
38
|
return Promise.all(promises);
|
|
31
39
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
/*
|
|
41
|
+
* Write files to the project folder (folder where 'webapp',
|
|
42
|
+
* 'package.json', 'ui5.yaml' located), use writeInProject method.
|
|
43
|
+
* @param dir The directory to write files to.
|
|
44
|
+
* @param files A Map of file paths and their contents.
|
|
45
|
+
* @returns A promise that resolves when all files have been written.
|
|
46
|
+
*/
|
|
47
|
+
static writeInProject(dir, files) {
|
|
48
|
+
return ResourceUtil.write(path.join("./", dir), files);
|
|
49
|
+
}
|
|
50
|
+
/*
|
|
51
|
+
* Search files in the given folder, excluding specified glob patterns.
|
|
52
|
+
* NOTE: to search in project folder (folder where 'webapp',
|
|
53
|
+
* 'package.json', 'ui5.yaml' located), use byGlobInProject method.
|
|
54
|
+
* @param dir The directory to search in.
|
|
55
|
+
* @param pattern The glob pattern to match files, e.g., "/ui5AppInfo.json".
|
|
56
|
+
* @param excludes An array of glob patterns to exclude from the search.
|
|
57
|
+
* @returns A promise that resolves to a Map of file paths and their contents.
|
|
58
|
+
*/
|
|
59
|
+
static byGlob(dir, pattern, excludes = []) {
|
|
60
|
+
const adapter = resourceFactory.createAdapter({
|
|
61
|
+
fsBasePath: dir,
|
|
62
|
+
virBasePath: "/",
|
|
63
|
+
excludes
|
|
64
|
+
});
|
|
65
|
+
return adapter.byGlob(pattern).then((resources) => this.toFileMap(resources));
|
|
66
|
+
}
|
|
67
|
+
/*
|
|
68
|
+
* Search files in the adaptation project (folder where 'webapp',
|
|
69
|
+
* 'package.json', 'ui5.yaml' located), excluding specified glob patterns.
|
|
70
|
+
* @param pattern The glob pattern to match files, e.g., "/ui5AppInfo.json".
|
|
71
|
+
* @param excludes An array of glob patterns to exclude from the search.
|
|
72
|
+
* @returns A promise that resolves to a Map of file paths and their contents.
|
|
73
|
+
*/
|
|
74
|
+
static byGlobInProject(pattern, excludes = []) {
|
|
75
|
+
return ResourceUtil.byGlob("./", pattern, [
|
|
76
|
+
"/node_modules",
|
|
77
|
+
"/dist",
|
|
78
|
+
"/.adp/reuse"
|
|
79
|
+
].concat(excludes));
|
|
80
|
+
}
|
|
81
|
+
/*
|
|
82
|
+
* Read the file by filepath from the project root (folder where 'webapp',
|
|
83
|
+
* 'package.json', 'ui5.yaml' located).
|
|
84
|
+
* @param filepath The relative file path from the project root (e.g. 'ui5AppInfo.json').
|
|
85
|
+
* @returns A promise that resolves to the file content as a string.
|
|
86
|
+
*/
|
|
87
|
+
static async readInProject(filepath) {
|
|
88
|
+
try {
|
|
89
|
+
return await fs.readFile(path.resolve(process.cwd(), filepath), UTF8);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
const isProjectRoot = await ResourceUtil.fileExists(path.join(process.cwd(), "ui5.yaml"));
|
|
93
|
+
if (!isProjectRoot) {
|
|
94
|
+
throw new Error(`Please make sure that build has been started from the project root: ${error?.message ?? ""}`);
|
|
43
95
|
}
|
|
96
|
+
throw error;
|
|
44
97
|
}
|
|
45
98
|
}
|
|
46
|
-
static read(folder) {
|
|
47
|
-
const files = new Map();
|
|
48
|
-
this._read(folder, folder, files);
|
|
49
|
-
return files;
|
|
50
|
-
}
|
|
51
99
|
static getString(resource) {
|
|
52
100
|
return resource.getBuffer().then((buffer) => buffer.toString(UTF8));
|
|
53
101
|
}
|
|
@@ -57,6 +105,23 @@ export default class ResourceUtil {
|
|
|
57
105
|
static setString(resource, str) {
|
|
58
106
|
resource.setBuffer(Buffer.from(str, UTF8));
|
|
59
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Check whether a file or directory exists (non-throwing).
|
|
110
|
+
* @param filePath Absolute or relative path
|
|
111
|
+
* @returns true if the path exists, false if not
|
|
112
|
+
*/
|
|
113
|
+
static async fileExists(filePath) {
|
|
114
|
+
try {
|
|
115
|
+
await fs.access(filePath);
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
if (e?.code === "ENOENT") {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
throw e;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
60
125
|
static createResource(filename, projectNamespace, content) {
|
|
61
126
|
return resourceFactory.createResource({
|
|
62
127
|
path: this.getResourcePath(projectNamespace, filename),
|
|
@@ -65,7 +130,7 @@ export default class ResourceUtil {
|
|
|
65
130
|
}
|
|
66
131
|
static async toFileMap(resources, projectNamespace) {
|
|
67
132
|
const files = new Map();
|
|
68
|
-
const rootFolderLength = ResourceUtil.getRootFolder(projectNamespace).length;
|
|
133
|
+
const rootFolderLength = projectNamespace ? ResourceUtil.getRootFolder(projectNamespace).length : 0;
|
|
69
134
|
for (const resource of resources) {
|
|
70
135
|
files.set(resource.getPath().substring(rootFolderLength + 1), await ResourceUtil.getString(resource));
|
|
71
136
|
}
|
package/eslint.config.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as eslintimport from "eslint-plugin-import";
|
|
|
3
3
|
import eslint from "@eslint/js";
|
|
4
4
|
import tseslint from "typescript-eslint";
|
|
5
5
|
|
|
6
|
-
export default tseslint.config(
|
|
6
|
+
export default tseslint.config([
|
|
7
7
|
eslint.configs.recommended,
|
|
8
8
|
...tseslint.configs.recommendedTypeChecked,
|
|
9
9
|
{
|
|
@@ -12,7 +12,8 @@ export default tseslint.config(
|
|
|
12
12
|
project: [
|
|
13
13
|
"./tsconfig.json",
|
|
14
14
|
"./test/lib/tsconfig.json",
|
|
15
|
-
"./scripts/tsconfig.json"
|
|
15
|
+
"./scripts/tsconfig.json",
|
|
16
|
+
"./rollup/tsconfig.json"
|
|
16
17
|
],
|
|
17
18
|
tsconfigRootDir: import.meta.dirname,
|
|
18
19
|
},
|
|
@@ -65,4 +66,4 @@ export default tseslint.config(
|
|
|
65
66
|
"@typescript-eslint/no-unused-expressions": "off"
|
|
66
67
|
},
|
|
67
68
|
}
|
|
68
|
-
);
|
|
69
|
+
]);
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui5/task-adaptation",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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
8
|
"lint": "eslint ./src ./test/lib",
|
|
9
|
-
"dev": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx
|
|
10
|
-
"perf": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx
|
|
9
|
+
"dev": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx 'test/lib/**/*.spec.ts'",
|
|
10
|
+
"perf": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx 'test/lib/**/*.perf.ts'",
|
|
11
11
|
"coverage": "c8 npm run dev",
|
|
12
12
|
"preversion": "npm test",
|
|
13
13
|
"version": "git-chglog --next-tag v$npm_package_version -o CHANGELOG.md && git add CHANGELOG.md",
|
|
14
14
|
"prepublishOnly": "git push --follow-tags",
|
|
15
15
|
"release-note": "git-chglog -c .chglog/release-config.yml v$npm_package_version",
|
|
16
|
-
"rollup": "tsx
|
|
16
|
+
"rollup": "tsx rollup/rollup.ts",
|
|
17
17
|
"build": "npm run rollup && tsc -p ./",
|
|
18
18
|
"download-metadata": "tsx scripts/metadataDownloadHelper.ts"
|
|
19
19
|
},
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"author": "SAP SE",
|
|
34
34
|
"license": "Apache-2.0",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@sap-ux/axios-extension": "^1.
|
|
37
|
-
"@sap-ux/btp-utils": "^1.
|
|
38
|
-
"@sap-ux/store": "^
|
|
39
|
-
"@sap-ux/system-access": "^0.
|
|
36
|
+
"@sap-ux/axios-extension": "^1.22.9",
|
|
37
|
+
"@sap-ux/btp-utils": "^1.1.3",
|
|
38
|
+
"@sap-ux/store": "^1.1.4",
|
|
39
|
+
"@sap-ux/system-access": "^0.6.18",
|
|
40
40
|
"@sap/cf-tools": "^3.2.2",
|
|
41
41
|
"@ui5/fs": "^4.0.1",
|
|
42
42
|
"@ui5/logger": "^4.0.1",
|
|
@@ -46,12 +46,11 @@
|
|
|
46
46
|
"dotenv": "^16.0.3",
|
|
47
47
|
"filenamify": "^6.0.0",
|
|
48
48
|
"jsdom": "^23.0.1",
|
|
49
|
-
"temp-dir": "^2.0.0",
|
|
50
49
|
"transliteration": "^2.3.5",
|
|
51
50
|
"xml-js": "^1.6.11"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
54
|
-
"@buxlabs/amd-to-es6": "^0.16.
|
|
53
|
+
"@buxlabs/amd-to-es6": "^0.16.4",
|
|
55
54
|
"@octokit/plugin-retry": "^8.0.1",
|
|
56
55
|
"@octokit/rest": "^22.0.0",
|
|
57
56
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
@@ -65,29 +64,29 @@
|
|
|
65
64
|
"@types/semver": "^7.3.8",
|
|
66
65
|
"@types/sinon": "^10.0.16",
|
|
67
66
|
"@types/yargs": "^17.0.33",
|
|
68
|
-
"@ui5/builder": "^4.
|
|
69
|
-
"@ui5/project": "^4.0.
|
|
67
|
+
"@ui5/builder": "^4.1.3",
|
|
68
|
+
"@ui5/project": "^4.0.9",
|
|
70
69
|
"amdextract": "^3.0.0",
|
|
71
70
|
"builtin-modules": "^3.2.0",
|
|
72
71
|
"c8": "^10.1.3",
|
|
73
|
-
"chai": "^
|
|
74
|
-
"chai-as-promised": "^
|
|
72
|
+
"chai": "^6.2.1",
|
|
73
|
+
"chai-as-promised": "^8.0.2",
|
|
75
74
|
"eslint": "^9.22.0",
|
|
76
75
|
"eslint-plugin-import": "^2.31.0",
|
|
77
|
-
"esmock": "^2.
|
|
78
|
-
"glob": "^
|
|
76
|
+
"esmock": "^2.7.3",
|
|
77
|
+
"glob": "^13.0.0",
|
|
79
78
|
"js-yaml": "^4.1.0",
|
|
80
79
|
"meriyah": "^6.0.3",
|
|
81
80
|
"minimatch": "^9.0.3",
|
|
82
|
-
"mocha": "^11.
|
|
81
|
+
"mocha": "^11.7.5",
|
|
83
82
|
"mock-require": "^3.0.3",
|
|
84
83
|
"rollup": "^4.24.0",
|
|
85
84
|
"semver": "^7.3.5",
|
|
86
85
|
"sinon": "^18.0.1",
|
|
87
86
|
"source-map-support": "^0.5.19",
|
|
88
|
-
"tsx": "^4.
|
|
89
|
-
"typescript": "^5.
|
|
90
|
-
"typescript-eslint": "^8.
|
|
87
|
+
"tsx": "^4.21.0",
|
|
88
|
+
"typescript": "^5.9.3",
|
|
89
|
+
"typescript-eslint": "^8.48.1",
|
|
91
90
|
"yargs": "^17.7.2"
|
|
92
91
|
},
|
|
93
92
|
"c8": {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { parse } from "meriyah";
|
|
2
|
+
import { traverse } from "../src/util/commonUtil.js";
|
|
3
|
+
|
|
4
|
+
export default function convert(content: string) {
|
|
5
|
+
return [
|
|
6
|
+
extractEsmClass
|
|
7
|
+
].reduce((result, converter) => converter(result), content);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function extractEsmClass(content: string) {
|
|
11
|
+
const result = parse(content, { ranges: true });
|
|
12
|
+
let classCode: { start: number, end: number } | undefined;
|
|
13
|
+
traverse(result, [], (json, key) => {
|
|
14
|
+
if (key === "type" && json[key] === "ClassDeclaration") {
|
|
15
|
+
if (classCode) {
|
|
16
|
+
throw new Error("Only one class declaration per module is allowed");
|
|
17
|
+
}
|
|
18
|
+
classCode = json;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return classCode && "export default " + content.substring(classCode.start, classCode.end) || content;
|
|
22
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const RegistrationBuild: any;
|
|
2
|
+
|
|
3
|
+
export declare class RawApplier {
|
|
4
|
+
static applyChanges(changeHandlers: any[], manifest: any, changes: AppDescriptorChange[], strategy: any): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export declare class AppDescriptorChange {
|
|
8
|
+
constructor(change: any);
|
|
9
|
+
getLayer(): string;
|
|
10
|
+
getChangeType(): string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export declare class V2MetadataConverter {
|
|
14
|
+
convertXMLMetadata(jsdom: any): any;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export declare class V4MetadataConverter {
|
|
18
|
+
convertXMLMetadata(jsdom: any): any;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare class URI {
|
|
22
|
+
constructor(relativeUrl: string);
|
|
23
|
+
absoluteTo(url: string): string;
|
|
24
|
+
static parse(url: string): { path: string };
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//Flex
|
|
2
|
+
import AppDescriptorChange from "sap/ui/fl/apply/_internal/flexObjects/AppDescriptorChange";
|
|
3
|
+
import RawApplier from "sap/ui/fl/apply/_internal/changes/descriptor/RawApplier";
|
|
4
|
+
import RegistrationBuild from "sap/ui/fl/apply/_internal/changes/descriptor/RegistrationBuild";
|
|
5
|
+
//OData
|
|
6
|
+
import URI from "sap/ui/thirdparty/URI";
|
|
7
|
+
import V2MetadataConverter from "sap/ui/model/odata/v4/lib/_V2MetadataConverter";
|
|
8
|
+
import V4MetadataConverter from "sap/ui/model/odata/v4/lib/_V4MetadataConverter";
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
//Flex
|
|
12
|
+
AppDescriptorChange,
|
|
13
|
+
RawApplier,
|
|
14
|
+
RegistrationBuild,
|
|
15
|
+
//OData
|
|
16
|
+
URI,
|
|
17
|
+
V4MetadataConverter,
|
|
18
|
+
V2MetadataConverter
|
|
19
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as rollup from "rollup";
|
|
2
|
+
import * as builtins from "builtin-modules";
|
|
3
|
+
import ui5 from "./ui5Resolve.js";
|
|
4
|
+
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export default abstract class Bundler {
|
|
8
|
+
|
|
9
|
+
static async run(resources: Map<string, any>, input: string, output: string, skipTransformation: string[] = []): Promise<void> {
|
|
10
|
+
if (!skipTransformation.includes(input)) {
|
|
11
|
+
skipTransformation.push(input);
|
|
12
|
+
}
|
|
13
|
+
const inputOptions = <rollup.RollupOptions>{
|
|
14
|
+
input,
|
|
15
|
+
plugins: [
|
|
16
|
+
ui5({
|
|
17
|
+
resources,
|
|
18
|
+
skipTransformation,
|
|
19
|
+
output
|
|
20
|
+
}),
|
|
21
|
+
nodeResolve({
|
|
22
|
+
preferBuiltins: true
|
|
23
|
+
})
|
|
24
|
+
],
|
|
25
|
+
external: builtins
|
|
26
|
+
};
|
|
27
|
+
const bundle = await rollup.rollup(inputOptions);
|
|
28
|
+
const outputOptions = <rollup.RollupOptions>{
|
|
29
|
+
file: output,
|
|
30
|
+
format: "esm"
|
|
31
|
+
};
|
|
32
|
+
await bundle.write(outputOptions);
|
|
33
|
+
await bundle.close();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ${copyright}
|
|
3
|
+
*/
|
|
4
|
+
sap.ui.define([
|
|
5
|
+
], (
|
|
6
|
+
) => {
|
|
7
|
+
"use strict";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The base Configuration.
|
|
11
|
+
*
|
|
12
|
+
* @author SAP SE
|
|
13
|
+
* @version ${version}
|
|
14
|
+
* @private
|
|
15
|
+
* @ui5-restricted sap.ui.core, sap.fl, sap.ui.intergration, sap.ui.export
|
|
16
|
+
* @alias module:sap/base/config
|
|
17
|
+
* @borrows module:sap/base/config/_Configuration.get as get
|
|
18
|
+
* @borrows module:sap/base/config/_Configuration.Type as Type
|
|
19
|
+
* @namespace
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const _Configuration = { _: {} };
|
|
23
|
+
|
|
24
|
+
const internalConfig = new Map();
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Returns a writable base configuration instance
|
|
28
|
+
* @returns {module:sap/base/config} The writable base configuration
|
|
29
|
+
* @private
|
|
30
|
+
* @ui5-restricted sap.ui.core, sap.fl
|
|
31
|
+
*/
|
|
32
|
+
_Configuration.getWritableInstance = () => {
|
|
33
|
+
return {
|
|
34
|
+
get(obj) {
|
|
35
|
+
internalConfig.get(obj.name);
|
|
36
|
+
},
|
|
37
|
+
set(name, obj) {
|
|
38
|
+
internalConfig.set(name, obj);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Attaches the <code>fnFunction</code> event handler to the {@link #event:invalidated invalidated} event
|
|
45
|
+
*
|
|
46
|
+
* @param {function} fnFunction The function to be called when the event occurs
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
function attachInvalidated() {
|
|
50
|
+
}
|
|
51
|
+
_Configuration._.attachInvalidated = attachInvalidated;
|
|
52
|
+
|
|
53
|
+
const origInvalidate = _Configuration._.invalidate;
|
|
54
|
+
_Configuration._.invalidate = () => {
|
|
55
|
+
origInvalidate();
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return _Configuration;
|
|
59
|
+
});
|
|
@@ -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);
|
package/rollup/rollup.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import * as semver from "semver";
|
|
4
|
+
import * as yaml from "js-yaml";
|
|
5
|
+
import Bundler from "./bundler.js";
|
|
6
|
+
import { dirname } from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
|
|
9
|
+
import * as resourceFactory from "@ui5/fs/resourceFactory";
|
|
10
|
+
import { graphFromPackageDependencies } from "@ui5/project/graph";
|
|
11
|
+
import { getLogger } from "@ui5/logger";
|
|
12
|
+
|
|
13
|
+
const log = getLogger("rollup-plugin-ui5-resolve-task-adaptation");
|
|
14
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
|
|
16
|
+
const projectPaths = [
|
|
17
|
+
path.resolve(__dirname, "project")
|
|
18
|
+
];
|
|
19
|
+
const LATEST_VERSION_PLACEHOLDER = "0.0.0";
|
|
20
|
+
|
|
21
|
+
export default class Builder {
|
|
22
|
+
|
|
23
|
+
static async getProjectInfo(projectPaths: string[]) {
|
|
24
|
+
for (const cwd of projectPaths) {
|
|
25
|
+
try {
|
|
26
|
+
const options = <any>{
|
|
27
|
+
cwd
|
|
28
|
+
};
|
|
29
|
+
const version = this.validateProjectSettings(cwd);
|
|
30
|
+
if (version === LATEST_VERSION_PLACEHOLDER) {
|
|
31
|
+
options.versionOverride = "latest";
|
|
32
|
+
}
|
|
33
|
+
return await graphFromPackageDependencies(options);
|
|
34
|
+
} catch (error: any) {
|
|
35
|
+
log.info(`${error.message}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static validateProjectSettings(projectPath: string): string {
|
|
41
|
+
const FRAMEWORK_TYPES = ["OpenUI5", "SAPUI5"];
|
|
42
|
+
const content = fs.readFileSync(path.join(projectPath, "ui5.yaml"), { encoding: "utf-8" });
|
|
43
|
+
const yamlJson = <any>yaml.load(content);
|
|
44
|
+
const framework = yamlJson["framework"];
|
|
45
|
+
if (!FRAMEWORK_TYPES.includes(framework.name)) {
|
|
46
|
+
throw new Error(`UI5 framework name is incorrect, possible values: ${FRAMEWORK_TYPES.join(" or ")}`);
|
|
47
|
+
}
|
|
48
|
+
if (!semver.valid(framework.version)) {
|
|
49
|
+
throw new Error(`UI5 framework version should correspond semantic version standard, e.g: 1.85.2`);
|
|
50
|
+
}
|
|
51
|
+
return framework.version;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static getBundledUI5Version(destination: string) {
|
|
55
|
+
const bundleFilePath = path.join(process.cwd(), destination);
|
|
56
|
+
if (fs.existsSync(bundleFilePath)) {
|
|
57
|
+
const bundle = fs.readFileSync(bundleFilePath, { encoding: "utf-8" });
|
|
58
|
+
const version = bundle.substring(2, bundle.indexOf("\n"));
|
|
59
|
+
return semver.coerce(version);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static async getResources(namespaces: Map<string, string[]>, projectGraph: any): Promise<Map<string, any>> {
|
|
64
|
+
const fsBasePaths = new Set<string>();
|
|
65
|
+
const adapters = new Map<string, any>();
|
|
66
|
+
for (const project of [...projectGraph.getProjects("rollup")]) {
|
|
67
|
+
const fsBasePath = project.getSourcePath();
|
|
68
|
+
if (!fsBasePaths.has(fsBasePath)) {
|
|
69
|
+
adapters.set(project.getNamespace(), resourceFactory.createReader({
|
|
70
|
+
fsBasePath,
|
|
71
|
+
virBasePath: "/resources/"
|
|
72
|
+
}));
|
|
73
|
+
fsBasePaths.add(fsBasePath);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const resources = new Map<string, any>();
|
|
78
|
+
for (const [namespace, adapter] of adapters.entries()) {
|
|
79
|
+
const patterns = namespaces.get(namespace);
|
|
80
|
+
if (patterns) {
|
|
81
|
+
for (const pattern of patterns) {
|
|
82
|
+
const result = await adapter.byGlob(pattern) as any[];
|
|
83
|
+
result.forEach(resource => resources.set(resource.getPath(), resource));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return resources;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static copyTypeDefinition() {
|
|
92
|
+
fs.copyFileSync(path.join(__dirname, "bundle.d.ts"), path.join(process.cwd(), "dist", "bundle.d.ts"))
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static async run(): Promise<void> {
|
|
96
|
+
const project = await this.getProjectInfo(projectPaths);
|
|
97
|
+
if (!project) {
|
|
98
|
+
throw new Error("ui5.yaml is not found or incorrect");
|
|
99
|
+
}
|
|
100
|
+
const namespaces = new Map([
|
|
101
|
+
["sap/fe/core", [
|
|
102
|
+
"/resources/sap/fe/core/**"
|
|
103
|
+
]],
|
|
104
|
+
["sap/ui/fl", [
|
|
105
|
+
"/resources/sap/ui/fl/**"
|
|
106
|
+
]],
|
|
107
|
+
["sap/ui/core", [
|
|
108
|
+
"/resources/ui5loader-autoconfig.js",
|
|
109
|
+
"/resources/sap/base/**",
|
|
110
|
+
"/resources/sap/ui/{base,thirdparty,model,util}/**"
|
|
111
|
+
]],
|
|
112
|
+
["sap/suite/ui/generic/template", [
|
|
113
|
+
"/resources/sap/suite/ui/generic/template/**"
|
|
114
|
+
]]
|
|
115
|
+
]);
|
|
116
|
+
const resources = await this.getResources(namespaces, project);
|
|
117
|
+
await Bundler.run(
|
|
118
|
+
resources,
|
|
119
|
+
"bundleDefinition.js",
|
|
120
|
+
"./dist/bundle.js",
|
|
121
|
+
[
|
|
122
|
+
"sap/ui/performance/Measurement"
|
|
123
|
+
]
|
|
124
|
+
);
|
|
125
|
+
this.copyTypeDefinition();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (process.argv.length === 2) {
|
|
130
|
+
const start = Date.now();
|
|
131
|
+
await Builder.run();
|
|
132
|
+
log.info(`Bundled in ${Date.now() - start} ms`);
|
|
133
|
+
}
|