@ui5/task-adaptation 1.5.2 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.hyperspace/pull_request_bot.json +19 -0
- package/CHANGELOG.md +9 -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/model/authenticationError.d.ts +3 -0
- package/dist/model/authenticationError.js +8 -0
- package/dist/util/cfUtil.d.ts +8 -1
- package/dist/util/cfUtil.js +16 -8
- package/dist/util/filesUtil.d.ts +3 -2
- package/dist/util/filesUtil.js +20 -4
- package/dist/util/renamingHandlers/jsonRenamingHandler.d.ts +12 -0
- package/dist/util/renamingHandlers/jsonRenamingHandler.js +34 -0
- package/dist/util/renamingHandlers/manifestRenamingHandler.d.ts +4 -5
- package/dist/util/renamingHandlers/manifestRenamingHandler.js +7 -18
- 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default class CacheHolder {
|
|
2
2
|
private static TEMP_TASK_DIR;
|
|
3
3
|
private static getTempDir;
|
|
4
|
-
static read(repoName: string, token: string): Map<string, string
|
|
4
|
+
static read(repoName: string, token: string): Promise<Map<string, string>>;
|
|
5
5
|
static write(repoName: string, token: string, files: Map<string, string>): Promise<void>;
|
|
6
6
|
private static isValid;
|
|
7
7
|
/**
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import * as fsPromises from "fs/promises";
|
|
3
3
|
import * as path from "path";
|
|
4
|
+
import * as os from "node:os";
|
|
4
5
|
import ResourceUtil from "../util/resourceUtil.js";
|
|
5
6
|
import encodeFilename from "filenamify";
|
|
6
7
|
import { getLogger } from "@ui5/logger";
|
|
7
|
-
import tempDir from "temp-dir";
|
|
8
8
|
const log = getLogger("@ui5/task-adaptation::CacheHolder");
|
|
9
9
|
export default class CacheHolder {
|
|
10
10
|
static TEMP_TASK_DIR = "ui5-task-adaptation";
|
|
11
11
|
static getTempDir(...paths) {
|
|
12
|
-
return path.join(
|
|
12
|
+
return path.join(os.tmpdir(), this.TEMP_TASK_DIR, ...paths.map(part => encodeFilename(part, { replacement: "_" })));
|
|
13
13
|
}
|
|
14
14
|
static read(repoName, token) {
|
|
15
15
|
const directory = this.getTempDir(repoName, token);
|
|
16
16
|
if (this.isValid(repoName, "repoName") && this.isValid(token, "token") && fs.existsSync(directory)) {
|
|
17
|
-
return ResourceUtil.
|
|
17
|
+
return ResourceUtil.byGlob(directory, "**/*");
|
|
18
18
|
}
|
|
19
|
+
return Promise.resolve(new Map());
|
|
19
20
|
}
|
|
20
21
|
static async write(repoName, token, files) {
|
|
21
22
|
this.delete(repoName);
|
|
@@ -40,7 +41,7 @@ export default class CacheHolder {
|
|
|
40
41
|
* Clears all cached files
|
|
41
42
|
*/
|
|
42
43
|
static clear() {
|
|
43
|
-
this.deleteDir(path.join(
|
|
44
|
+
this.deleteDir(path.join(os.tmpdir(), this.TEMP_TASK_DIR));
|
|
44
45
|
}
|
|
45
46
|
static deleteDir(directory) {
|
|
46
47
|
if (fs.existsSync(directory)) {
|
|
@@ -67,9 +68,10 @@ export function cached() {
|
|
|
67
68
|
return function (_target, _propertyKey, descriptor) {
|
|
68
69
|
const originalValue = descriptor.value;
|
|
69
70
|
descriptor.value = async function (...args) {
|
|
70
|
-
let files = CacheHolder.read(args[0], args[1]);
|
|
71
|
+
let files = await CacheHolder.read(args[0], args[1]);
|
|
71
72
|
CacheHolder.clearOutdatedExcept(args[0]);
|
|
72
|
-
if (files
|
|
73
|
+
if (files.size === 0) {
|
|
74
|
+
log.verbose(`Cache repo '${args[0]}' with token '${args[1]}' does not contain files. Fetching...`);
|
|
73
75
|
files = await originalValue.apply(this, args);
|
|
74
76
|
await CacheHolder.write(args[0], args[1], files);
|
|
75
77
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export default class AuthenticationError extends Error {
|
|
2
|
+
constructor(details) {
|
|
3
|
+
super(details);
|
|
4
|
+
this.name = "AuthenticationError";
|
|
5
|
+
this.message = "Authentication error. Use 'cf login' to authenticate in Cloud Foundry" + (details ? `: ${details}` : ".");
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=authenticationError.js.map
|
package/dist/util/cfUtil.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export default class CFUtil {
|
|
|
15
15
|
private static createServiceKey;
|
|
16
16
|
private static deleteServiceKeyUnsafe;
|
|
17
17
|
private static getServiceInstance;
|
|
18
|
-
static
|
|
18
|
+
static processCfErrors(errors?: ICfError[]): void;
|
|
19
19
|
static requestCfApi(url: string): Promise<IResource[]>;
|
|
20
20
|
static getOAuthToken(): Promise<string>;
|
|
21
21
|
private static cfExecute;
|
|
@@ -76,3 +76,10 @@ export default class CFUtil {
|
|
|
76
76
|
*/
|
|
77
77
|
static getSpaceGuid(spaceGuid?: string): Promise<string>;
|
|
78
78
|
}
|
|
79
|
+
interface ICfError {
|
|
80
|
+
code: number;
|
|
81
|
+
title: string;
|
|
82
|
+
detail: string;
|
|
83
|
+
[key: string]: any;
|
|
84
|
+
}
|
|
85
|
+
export {};
|
package/dist/util/cfUtil.js
CHANGED
|
@@ -3,6 +3,7 @@ import { getSpaceGuidThrowIfUndefined } from "@sap/cf-tools/out/src/utils.js";
|
|
|
3
3
|
import { Cli } from "@sap/cf-tools/out/src/cli.js";
|
|
4
4
|
import { eFilters } from "@sap/cf-tools/out/src/types.js";
|
|
5
5
|
import { getLogger } from "@ui5/logger";
|
|
6
|
+
import AuthenticationError from "../model/authenticationError.js";
|
|
6
7
|
const log = getLogger("@ui5/task-adaptation::CFUtil");
|
|
7
8
|
export default class CFUtil {
|
|
8
9
|
/**
|
|
@@ -103,19 +104,20 @@ export default class CFUtil {
|
|
|
103
104
|
guid: service.guid
|
|
104
105
|
}));
|
|
105
106
|
}
|
|
106
|
-
static
|
|
107
|
-
if (
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
throw new
|
|
107
|
+
static processCfErrors(errors) {
|
|
108
|
+
if (!errors || errors.length === 0) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const authError = errors.find(e => e.title === "CF-NotAuthenticated" || e.code === 10002);
|
|
112
|
+
if (authError) {
|
|
113
|
+
throw new AuthenticationError(authError.detail);
|
|
113
114
|
}
|
|
115
|
+
throw new Error(`Failed sending request to Cloud Foundry: ${JSON.stringify(errors)}`);
|
|
114
116
|
}
|
|
115
117
|
static async requestCfApi(url) {
|
|
116
118
|
const response = await this.cfExecute(["curl", url]);
|
|
117
119
|
const json = this.parseJson(response);
|
|
118
|
-
this.
|
|
120
|
+
this.processCfErrors(json?.errors);
|
|
119
121
|
const resources = json?.resources;
|
|
120
122
|
const totalPages = json?.pagination?.total_pages;
|
|
121
123
|
if (totalPages > 1) {
|
|
@@ -142,11 +144,17 @@ export default class CFUtil {
|
|
|
142
144
|
if (errorValues?.length > 0) {
|
|
143
145
|
log.verbose(this.errorsToString(errorValues));
|
|
144
146
|
}
|
|
147
|
+
if (response.stdout === "\n") {
|
|
148
|
+
throw new AuthenticationError();
|
|
149
|
+
}
|
|
145
150
|
return response.stdout;
|
|
146
151
|
}
|
|
147
152
|
errors.add(response.error || response.stderr);
|
|
148
153
|
}
|
|
149
154
|
catch (error) {
|
|
155
|
+
if (error instanceof AuthenticationError) {
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
150
158
|
errors.add(error.message);
|
|
151
159
|
}
|
|
152
160
|
}
|
package/dist/util/filesUtil.d.ts
CHANGED
|
@@ -8,9 +8,10 @@ export default class FilesUtil {
|
|
|
8
8
|
* @returns A map of renamed files
|
|
9
9
|
*/
|
|
10
10
|
static rename(files: ReadonlyMap<string, string>, references: Map<string, string>): ReadonlyMap<string, string>;
|
|
11
|
+
private static getManifestSAPUI5DependencyIds;
|
|
11
12
|
private static getI18nPropertyKeys;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
|
-
* We might rename appVariantIdHierarchy, so we restore
|
|
15
|
+
* We might rename appVariantIdHierarchy and dependencies, so we restore them after the renaming.
|
|
15
16
|
*/
|
|
16
|
-
export declare function
|
|
17
|
+
export declare function restoreWhatShouldntBeRenamed(): (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => void;
|
package/dist/util/filesUtil.js
CHANGED
|
@@ -32,7 +32,10 @@ export default class FilesUtil {
|
|
|
32
32
|
*/
|
|
33
33
|
static rename(files, references) {
|
|
34
34
|
const IGNORE_EXTENSIONS = [".properties"];
|
|
35
|
-
const ignoreInString =
|
|
35
|
+
const ignoreInString = [
|
|
36
|
+
...this.getI18nPropertyKeys(files),
|
|
37
|
+
...this.getManifestSAPUI5DependencyIds(files)
|
|
38
|
+
];
|
|
36
39
|
return new Map(Array.from(files, ([filename, content]) => {
|
|
37
40
|
if (!IGNORE_EXTENSIONS.some(ext => filename.endsWith(ext))) {
|
|
38
41
|
// 5p. We pass replacements as ignores since we don't want to
|
|
@@ -45,6 +48,19 @@ export default class FilesUtil {
|
|
|
45
48
|
return [filename, content];
|
|
46
49
|
}));
|
|
47
50
|
}
|
|
51
|
+
static getManifestSAPUI5DependencyIds(files) {
|
|
52
|
+
const manifestFile = files.get("manifest.json");
|
|
53
|
+
if (manifestFile) {
|
|
54
|
+
const manifest = JSON.parse(manifestFile);
|
|
55
|
+
const dependencies = manifest["sap.ui5"]?.dependencies;
|
|
56
|
+
if (dependencies) {
|
|
57
|
+
const libs = dependencies.libs ? Object.keys(dependencies.libs) : [];
|
|
58
|
+
const components = dependencies.components ? Object.keys(dependencies.components) : [];
|
|
59
|
+
return [...libs, ...components];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
48
64
|
static getI18nPropertyKeys(files) {
|
|
49
65
|
const keys = new Set();
|
|
50
66
|
files.forEach((content, filename) => {
|
|
@@ -62,12 +78,12 @@ export default class FilesUtil {
|
|
|
62
78
|
}
|
|
63
79
|
}
|
|
64
80
|
__decorate([
|
|
65
|
-
|
|
81
|
+
restoreWhatShouldntBeRenamed()
|
|
66
82
|
], FilesUtil, "rename", null);
|
|
67
83
|
/**
|
|
68
|
-
* We might rename appVariantIdHierarchy, so we restore
|
|
84
|
+
* We might rename appVariantIdHierarchy and dependencies, so we restore them after the renaming.
|
|
69
85
|
*/
|
|
70
|
-
export function
|
|
86
|
+
export function restoreWhatShouldntBeRenamed() {
|
|
71
87
|
return function (_target, _propertyKey, descriptor) {
|
|
72
88
|
const handlers = [new ManifestRenamingHandler()];
|
|
73
89
|
const originalValue = descriptor.value;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IRenamingHandler } from "./renamingHandler.js";
|
|
2
|
+
export default abstract class JsonRenamingHandler implements IRenamingHandler {
|
|
3
|
+
private original;
|
|
4
|
+
protected abstract filePath: string;
|
|
5
|
+
protected abstract jsonPathsToRestore: string[];
|
|
6
|
+
before(files: ReadonlyMap<string, string>): void;
|
|
7
|
+
after(files: Map<string, string>): void;
|
|
8
|
+
protected store(obj: any, path: string): void;
|
|
9
|
+
protected restore(obj: any): void;
|
|
10
|
+
private getByPath;
|
|
11
|
+
private setByPath;
|
|
12
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export default class JsonRenamingHandler {
|
|
2
|
+
original = new Map();
|
|
3
|
+
before(files) {
|
|
4
|
+
const content = files.get(this.filePath);
|
|
5
|
+
if (content) {
|
|
6
|
+
const json = JSON.parse(content);
|
|
7
|
+
this.jsonPathsToRestore.forEach(path => this.store(json, path));
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
after(files) {
|
|
11
|
+
const content = files.get(this.filePath);
|
|
12
|
+
if (content) {
|
|
13
|
+
const json = JSON.parse(content);
|
|
14
|
+
this.restore(json);
|
|
15
|
+
files.set(this.filePath, JSON.stringify(json));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
store(obj, path) {
|
|
19
|
+
this.original.set(path, this.getByPath(obj, path.split("/")));
|
|
20
|
+
}
|
|
21
|
+
restore(obj) {
|
|
22
|
+
this.original.forEach((value, path) => this.setByPath(obj, value, path.split("/")));
|
|
23
|
+
}
|
|
24
|
+
getByPath(obj, path) {
|
|
25
|
+
return path.reduce((o, p) => (o && o[p]) || undefined, obj);
|
|
26
|
+
}
|
|
27
|
+
setByPath(obj, value, path) {
|
|
28
|
+
const target = this.getByPath(obj, path.slice(0, -1));
|
|
29
|
+
if (target) {
|
|
30
|
+
target[path[path.length - 1]] = value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=jsonRenamingHandler.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class ManifestRenamingHandler
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
after(files: Map<string, string>): void;
|
|
1
|
+
import JsonRenamingHandler from "./jsonRenamingHandler.js";
|
|
2
|
+
export default class ManifestRenamingHandler extends JsonRenamingHandler {
|
|
3
|
+
protected readonly filePath = "manifest.json";
|
|
4
|
+
protected readonly jsonPathsToRestore: string[];
|
|
6
5
|
}
|
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
;
|
|
1
|
+
import JsonRenamingHandler from "./jsonRenamingHandler.js";
|
|
2
|
+
export default class ManifestRenamingHandler extends JsonRenamingHandler {
|
|
3
|
+
filePath = "manifest.json";
|
|
4
|
+
// path to the JSON properties, forward slash separated, e.g. "sap.ui5/appVariantIdHierarchy"
|
|
5
|
+
jsonPathsToRestore = [
|
|
6
|
+
"sap.ui5/appVariantIdHierarchy"
|
|
7
|
+
];
|
|
19
8
|
}
|
|
20
9
|
//# sourceMappingURL=manifestRenamingHandler.js.map
|
|
@@ -3,11 +3,19 @@ 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
|
-
|
|
7
|
-
static
|
|
6
|
+
static writeInProject(dir: string, files: Map<string, string>): Promise<void[]>;
|
|
7
|
+
static byGlob(dir: string, pattern: string, excludes?: string[]): Promise<Map<string, string>>;
|
|
8
|
+
static byGlobInProject(pattern: string, excludes?: string[]): Promise<Map<string, string>>;
|
|
9
|
+
static readInProject(filepath: string): Promise<string>;
|
|
8
10
|
static getString(resource: any): Promise<string>;
|
|
9
11
|
static getJson(resource: any): Promise<any>;
|
|
10
12
|
static setString(resource: any, str: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* Check whether a file or directory exists (non-throwing).
|
|
15
|
+
* @param filePath Absolute or relative path
|
|
16
|
+
* @returns true if the path exists, false if not
|
|
17
|
+
*/
|
|
18
|
+
private static fileExists;
|
|
11
19
|
static createResource(filename: string, projectNamespace: string, content: string): any;
|
|
12
|
-
static toFileMap(resources: ReadonlyArray<Resource>, projectNamespace
|
|
20
|
+
static toFileMap(resources: ReadonlyArray<Resource>, projectNamespace?: string): Promise<Map<string, string>>;
|
|
13
21
|
}
|
|
@@ -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
|
+
"/.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.5.
|
|
3
|
+
"version": "1.5.4",
|
|
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
|
+
};
|