@ui5/task-adaptation 1.6.5-rc.2 → 1.6.5-rc.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/CHANGELOG.md +12 -1
- package/REUSE.toml +1 -1
- package/dist/adapters/abapAdapter.d.ts +7 -5
- package/dist/adapters/abapAdapter.js +9 -11
- package/dist/adapters/adapter.d.ts +9 -5
- package/dist/adapters/adapter.js +20 -0
- package/dist/adapters/cfAdapter.d.ts +8 -5
- package/dist/adapters/cfAdapter.js +16 -10
- package/dist/adapters/commands/command.d.ts +26 -23
- package/dist/adapters/commands/command.js +73 -46
- package/dist/adapters/commands/fetchEndpointsCommand.d.ts +9 -0
- package/dist/adapters/commands/fetchEndpointsCommand.js +21 -0
- package/dist/adapters/commands/fetchPreviewResourcesCommand.d.ts +15 -0
- package/dist/adapters/commands/fetchPreviewResourcesCommand.js +103 -0
- package/dist/adapters/commands/filterFilesCommand.d.ts +4 -0
- package/dist/adapters/commands/filterFilesCommand.js +22 -0
- package/dist/adapters/commands/omitDeletedResourcesCommand.d.ts +10 -0
- package/dist/adapters/commands/omitDeletedResourcesCommand.js +31 -0
- package/dist/adapters/commands/processPreviewResourcesCommand.d.ts +9 -0
- package/dist/adapters/commands/processPreviewResourcesCommand.js +55 -0
- package/dist/adapters/commands/renameFilesCommand.d.ts +20 -0
- package/dist/{util/filesUtil.js → adapters/commands/renameFilesCommand.js} +34 -43
- package/dist/adapters/commands/writeResourcesCommand.d.ts +7 -0
- package/dist/adapters/commands/writeResourcesCommand.js +20 -0
- package/dist/adapters/commands/xsAppJsonEnhanceRoutesCommand.d.ts +3 -3
- package/dist/adapters/commands/xsAppJsonEnhanceRoutesCommand.js +4 -4
- package/dist/adapters/previewAdapter.d.ts +12 -6
- package/dist/adapters/previewAdapter.js +28 -7
- package/dist/annotations/abapAnnotationManager.js +1 -1
- package/dist/annotations/dataSource/dataSourceManager.d.ts +2 -1
- package/dist/annotations/dataSource/dataSourceManager.js +16 -7
- package/dist/{appVariantManager.d.ts → appVariant.d.ts} +2 -9
- package/dist/{appVariantManager.js → appVariant.js} +16 -28
- package/dist/{baseAppManager.js → baseApp.js} +6 -12
- package/dist/bundle.js +53 -12
- package/dist/cache/cacheHolder.d.ts +3 -3
- package/dist/cache/cacheHolder.js +8 -7
- package/dist/cache/cachedResource.d.ts +4 -0
- package/dist/cache/cachedResource.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +44 -69
- package/dist/landscapeConfiguration.d.ts +2 -2
- package/dist/landscapeConfiguration.js +39 -37
- package/dist/model/configuration.d.ts +1 -4
- package/dist/model/configuration.js +1 -1
- package/dist/model/types.d.ts +9 -2
- package/dist/repositories/abapProvider.js +2 -2
- package/dist/repositories/abapRepository.d.ts +6 -5
- package/dist/repositories/abapRepository.js +10 -11
- package/dist/repositories/html5Repository.d.ts +8 -5
- package/dist/repositories/html5Repository.js +18 -30
- package/dist/repositories/localRepository.d.ts +8 -12
- package/dist/repositories/localRepository.js +53 -43
- package/dist/repositories/repository.d.ts +3 -5
- package/dist/util/cf/xsAppJsonUtil.d.ts +16 -3
- package/dist/util/cf/xsAppJsonUtil.js +7 -18
- package/dist/util/commonUtil.d.ts +6 -0
- package/dist/util/commonUtil.js +17 -0
- package/dist/util/fsUtil.d.ts +2 -3
- package/dist/util/fsUtil.js +12 -33
- package/dist/util/renamingUtil.js +50 -82
- package/dist/util/resourceUtil.d.ts +21 -5
- package/dist/util/resourceUtil.js +52 -11
- package/dist/util/validator/abapConnectionValidator.d.ts +5 -0
- package/dist/util/validator/abapConnectionValidator.js +22 -0
- package/dist/util/validator/abapValidator.d.ts +2 -4
- package/dist/util/validator/abapValidator.js +4 -16
- package/dist/util/validator/validator.d.ts +1 -0
- package/dist/util/validator/validator.js +11 -0
- package/dist/util/workspaceManager.d.ts +9 -0
- package/dist/util/workspaceManager.js +46 -0
- package/dist/util/zipUtil.d.ts +1 -1
- package/dist/util/zipUtil.js +1 -1
- package/package.json +13 -13
- package/.hyperspace/pull_request_bot.json +0 -19
- package/dist/previewManager.d.ts +0 -14
- package/dist/previewManager.js +0 -141
- package/dist/util/filesUtil.d.ts +0 -19
- package/scripts/metadataDownloadHelper.ts +0 -88
- package/scripts/publish.ts +0 -256
- package/scripts/test-integration-prep.sh +0 -4
- /package/dist/{baseAppManager.d.ts → baseApp.d.ts} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import ResourceUtil from "../../util/resourceUtil.js";
|
|
2
|
+
import { PostCommand } from "./command.js";
|
|
3
|
+
export default class OmitDeletedResourcesCommand extends PostCommand {
|
|
4
|
+
taskUtil;
|
|
5
|
+
movedFiles;
|
|
6
|
+
resources;
|
|
7
|
+
projectNamespace;
|
|
8
|
+
constructor(taskUtil, movedFiles, resources = [], projectNamespace) {
|
|
9
|
+
super();
|
|
10
|
+
this.taskUtil = taskUtil;
|
|
11
|
+
this.movedFiles = movedFiles;
|
|
12
|
+
this.resources = resources;
|
|
13
|
+
this.projectNamespace = projectNamespace;
|
|
14
|
+
}
|
|
15
|
+
async execute(files) {
|
|
16
|
+
for (const resource of this.resources) {
|
|
17
|
+
const relativePath = ResourceUtil.relativeToRoot(resource.getPath(), this.projectNamespace);
|
|
18
|
+
if (!files.has(relativePath)) {
|
|
19
|
+
this.taskUtil.setTag(resource, this.taskUtil.STANDARD_TAGS.OmitFromBuildResult, true);
|
|
20
|
+
const newPath = this.movedFiles.get(relativePath);
|
|
21
|
+
if (newPath) {
|
|
22
|
+
const renamedContent = files.get(newPath);
|
|
23
|
+
if (renamedContent) {
|
|
24
|
+
resource.setString(renamedContent);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=omitDeletedResourcesCommand.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PostCommand } from "./command.js";
|
|
2
|
+
import { FetchFilesPromise, ServiceCredentials } from "../../model/types.js";
|
|
3
|
+
export default class ProcessPreviewResourcesCommand extends PostCommand {
|
|
4
|
+
private serviceCredentialsPromise;
|
|
5
|
+
private previewPromise;
|
|
6
|
+
constructor(serviceCredentialsPromise: Promise<ServiceCredentials | undefined>, previewPromise: Promise<FetchFilesPromise | undefined>);
|
|
7
|
+
execute(files: Map<string, string>): Promise<void>;
|
|
8
|
+
private collectReuseLibFiles;
|
|
9
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { PostCommand } from "./command.js";
|
|
2
|
+
import { getLogger } from "@ui5/logger";
|
|
3
|
+
import { fetchCredentialsAndEnhanceRoutes, merge, XSAPP_JSON_FILENAME } from "../../util/cf/xsAppJsonUtil.js";
|
|
4
|
+
import ResourceUtil from "../../util/resourceUtil.js";
|
|
5
|
+
import { REUSE_DIR } from "../../model/configuration.js";
|
|
6
|
+
const log = getLogger("@ui5/task-adaptation::ProcessPreviewResourcesCommand");
|
|
7
|
+
export default class ProcessPreviewResourcesCommand extends PostCommand {
|
|
8
|
+
serviceCredentialsPromise;
|
|
9
|
+
previewPromise;
|
|
10
|
+
constructor(serviceCredentialsPromise, previewPromise) {
|
|
11
|
+
super();
|
|
12
|
+
this.serviceCredentialsPromise = serviceCredentialsPromise;
|
|
13
|
+
this.previewPromise = previewPromise;
|
|
14
|
+
}
|
|
15
|
+
async execute(files) {
|
|
16
|
+
log.verbose(`Downloading reuse libraries to reuse folder`);
|
|
17
|
+
const baseAppXsAppJson = files.get(XSAPP_JSON_FILENAME);
|
|
18
|
+
const mergedFiles = await this.collectReuseLibFiles(await this.previewPromise, baseAppXsAppJson);
|
|
19
|
+
const xsAppJson = mergedFiles.get(XSAPP_JSON_FILENAME);
|
|
20
|
+
if (xsAppJson) {
|
|
21
|
+
const enhanced = await fetchCredentialsAndEnhanceRoutes(xsAppJson.toString("utf8"), this.serviceCredentialsPromise);
|
|
22
|
+
mergedFiles.set(XSAPP_JSON_FILENAME, Buffer.from(enhanced, "utf8"));
|
|
23
|
+
}
|
|
24
|
+
if (mergedFiles.size === 0) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
await ResourceUtil.writeInProject(REUSE_DIR, mergedFiles);
|
|
28
|
+
}
|
|
29
|
+
async collectReuseLibFiles(fetchLibsPromises, mergedXsAppJson) {
|
|
30
|
+
const mergedFiles = new Map();
|
|
31
|
+
if (!fetchLibsPromises) {
|
|
32
|
+
log.verbose("No reuse libraries defined in ui5AppInfo.json for preview");
|
|
33
|
+
return mergedFiles;
|
|
34
|
+
}
|
|
35
|
+
for (const [libName, libFilesPromise] of fetchLibsPromises) {
|
|
36
|
+
const libFiles = await libFilesPromise;
|
|
37
|
+
if (!libFiles || libFiles.size === 0) {
|
|
38
|
+
log.warn(`No files found in reuse library ${libName} for preview`);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
for (const [filename, content] of libFiles) {
|
|
42
|
+
if (filename.endsWith(XSAPP_JSON_FILENAME)) {
|
|
43
|
+
const xsAppText = content.toString("utf8");
|
|
44
|
+
mergedXsAppJson = mergedXsAppJson ? merge([xsAppText, mergedXsAppJson]) : xsAppText;
|
|
45
|
+
}
|
|
46
|
+
mergedFiles.set(filename, content);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (mergedXsAppJson) {
|
|
50
|
+
mergedFiles.set(XSAPP_JSON_FILENAME, Buffer.from(mergedXsAppJson, "utf8"));
|
|
51
|
+
}
|
|
52
|
+
return mergedFiles;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=processPreviewResourcesCommand.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PostCommand } from "./command.js";
|
|
2
|
+
export default class RenameFilesCommand extends PostCommand {
|
|
3
|
+
private references;
|
|
4
|
+
constructor(references: Map<string, string>);
|
|
5
|
+
execute(files: Map<string, string>): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* 1p. i18n.properties are not renamed and property keys are ignored during
|
|
8
|
+
* the renaming across the files.
|
|
9
|
+
* @param files - all files both base and appVariants
|
|
10
|
+
* @param references - Reference maps of the app variant
|
|
11
|
+
* @returns A map of renamed files
|
|
12
|
+
*/
|
|
13
|
+
rename(files: Map<string, string>, references: Map<string, string>): void;
|
|
14
|
+
private getManifestSAPUI5DependencyIds;
|
|
15
|
+
private getI18nPropertyKeys;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* We might rename appVariantIdHierarchy and dependencies, so we restore them after the renaming.
|
|
19
|
+
*/
|
|
20
|
+
export declare function restoreWhatShouldntBeRenamed(): (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
@@ -4,58 +4,47 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
return IGNORE_FILES.includes(filename);
|
|
17
|
-
};
|
|
18
|
-
const result = new Map();
|
|
19
|
-
files.forEach((content, filename) => {
|
|
20
|
-
if (!shouldIgnore(filename, content)) {
|
|
21
|
-
result.set(filename, content);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
return result;
|
|
7
|
+
import ManifestRenamingHandler from "../../util/renamingHandlers/manifestRenamingHandler.js";
|
|
8
|
+
import { renameMap } from "../../util/renamingUtil.js";
|
|
9
|
+
import { PostCommand } from "./command.js";
|
|
10
|
+
export default class RenameFilesCommand extends PostCommand {
|
|
11
|
+
references;
|
|
12
|
+
constructor(references) {
|
|
13
|
+
super();
|
|
14
|
+
this.references = references;
|
|
25
15
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return -1;
|
|
29
|
-
if (a.creation > b.creation)
|
|
30
|
-
return 1;
|
|
31
|
-
return 0;
|
|
16
|
+
async execute(files) {
|
|
17
|
+
this.rename(files, this.references);
|
|
32
18
|
}
|
|
33
19
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
20
|
+
* 1p. i18n.properties are not renamed and property keys are ignored during
|
|
21
|
+
* the renaming across the files.
|
|
22
|
+
* @param files - all files both base and appVariants
|
|
23
|
+
* @param references - Reference maps of the app variant
|
|
24
|
+
* @returns A map of renamed files
|
|
25
|
+
*/
|
|
26
|
+
rename(files, references) {
|
|
41
27
|
const IGNORE_EXTENSIONS = [".properties"];
|
|
42
28
|
const ignoreInString = [
|
|
43
29
|
...this.getI18nPropertyKeys(files),
|
|
44
30
|
...this.getManifestSAPUI5DependencyIds(files)
|
|
45
31
|
];
|
|
46
|
-
|
|
32
|
+
const updates = new Map();
|
|
33
|
+
for (const [filename, content] of files) {
|
|
47
34
|
if (!IGNORE_EXTENSIONS.some(ext => filename.endsWith(ext))) {
|
|
48
35
|
// 5p. We pass replacements as ignores since we don't want to
|
|
49
36
|
// rename them again. E.g. we replace app.id with
|
|
50
37
|
// customer.app.id, but if we found customer.app.id somewhere,
|
|
51
38
|
// because we applied changes or something, we don't want to
|
|
52
39
|
// rename it again to customer.customer.app.id.
|
|
53
|
-
|
|
40
|
+
updates.set(filename, renameMap(content, references, [...references.values(), ...ignoreInString]));
|
|
54
41
|
}
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
}
|
|
43
|
+
for (const [filename, content] of updates) {
|
|
44
|
+
files.set(filename, content);
|
|
45
|
+
}
|
|
57
46
|
}
|
|
58
|
-
|
|
47
|
+
getManifestSAPUI5DependencyIds(files) {
|
|
59
48
|
const manifestFile = files.get("manifest.json");
|
|
60
49
|
if (manifestFile) {
|
|
61
50
|
const manifest = JSON.parse(manifestFile);
|
|
@@ -68,7 +57,7 @@ export default class FilesUtil {
|
|
|
68
57
|
}
|
|
69
58
|
return [];
|
|
70
59
|
}
|
|
71
|
-
|
|
60
|
+
getI18nPropertyKeys(files) {
|
|
72
61
|
const keys = new Set();
|
|
73
62
|
files.forEach((content, filename) => {
|
|
74
63
|
if (filename.endsWith(".properties")) {
|
|
@@ -86,7 +75,7 @@ export default class FilesUtil {
|
|
|
86
75
|
}
|
|
87
76
|
__decorate([
|
|
88
77
|
restoreWhatShouldntBeRenamed()
|
|
89
|
-
],
|
|
78
|
+
], RenameFilesCommand.prototype, "rename", null);
|
|
90
79
|
/**
|
|
91
80
|
* We might rename appVariantIdHierarchy and dependencies, so we restore them after the renaming.
|
|
92
81
|
*/
|
|
@@ -95,12 +84,14 @@ export function restoreWhatShouldntBeRenamed() {
|
|
|
95
84
|
const handlers = [new ManifestRenamingHandler()];
|
|
96
85
|
const originalValue = descriptor.value;
|
|
97
86
|
descriptor.value = function (...args) {
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
handlers.forEach(handler => handler.
|
|
101
|
-
|
|
87
|
+
const files = args[0];
|
|
88
|
+
const references = args[1];
|
|
89
|
+
handlers.forEach(handler => handler.before(files));
|
|
90
|
+
originalValue.apply(this, [files, references]);
|
|
91
|
+
handlers.forEach(handler => handler.after(files));
|
|
92
|
+
return files;
|
|
102
93
|
};
|
|
103
94
|
};
|
|
104
95
|
}
|
|
105
96
|
;
|
|
106
|
-
//# sourceMappingURL=
|
|
97
|
+
//# sourceMappingURL=renameFilesCommand.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PostCommand } from "./command.js";
|
|
2
|
+
export default class WriteResourcesCommand extends PostCommand {
|
|
3
|
+
private workspace;
|
|
4
|
+
private projectNamespace;
|
|
5
|
+
constructor(workspace: any, projectNamespace: string);
|
|
6
|
+
execute(files: Map<string, string>): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import ResourceUtil from "../../util/resourceUtil.js";
|
|
2
|
+
import { PostCommand } from "./command.js";
|
|
3
|
+
export default class WriteResourcesCommand extends PostCommand {
|
|
4
|
+
workspace;
|
|
5
|
+
projectNamespace;
|
|
6
|
+
constructor(workspace, projectNamespace) {
|
|
7
|
+
super();
|
|
8
|
+
this.workspace = workspace;
|
|
9
|
+
this.projectNamespace = projectNamespace;
|
|
10
|
+
}
|
|
11
|
+
async execute(files) {
|
|
12
|
+
const writePromises = new Array();
|
|
13
|
+
files.forEach((content, filename) => {
|
|
14
|
+
const resource = ResourceUtil.createResource(filename, this.projectNamespace, content);
|
|
15
|
+
writePromises.push(this.workspace.write(resource));
|
|
16
|
+
});
|
|
17
|
+
await Promise.all(writePromises);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=writeResourcesCommand.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ServiceCredentials } from "../../model/types.js";
|
|
2
2
|
import { PostCommand } from "./command.js";
|
|
3
3
|
export default class XsAppJsonEnhanceRoutesCommand extends PostCommand {
|
|
4
|
-
private
|
|
5
|
-
constructor(
|
|
4
|
+
private serviceCredentialsPromise;
|
|
5
|
+
constructor(serviceCredentialsPromise: Promise<ServiceCredentials | undefined>);
|
|
6
6
|
execute(files: Map<string, string>): Promise<void>;
|
|
7
7
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { fetchCredentialsAndEnhanceRoutes } from "../../util/cf/xsAppJsonUtil.js";
|
|
2
2
|
import { PostCommand } from "./command.js";
|
|
3
3
|
export default class XsAppJsonEnhanceRoutesCommand extends PostCommand {
|
|
4
|
-
|
|
5
|
-
constructor(
|
|
4
|
+
serviceCredentialsPromise;
|
|
5
|
+
constructor(serviceCredentialsPromise) {
|
|
6
6
|
super();
|
|
7
|
-
this.
|
|
7
|
+
this.serviceCredentialsPromise = serviceCredentialsPromise;
|
|
8
8
|
}
|
|
9
9
|
async execute(files) {
|
|
10
10
|
let xsAppJson = files.get("xs-app.json");
|
|
11
11
|
if (xsAppJson) {
|
|
12
|
-
xsAppJson = await fetchCredentialsAndEnhanceRoutes(xsAppJson, this.
|
|
12
|
+
xsAppJson = await fetchCredentialsAndEnhanceRoutes(xsAppJson, this.serviceCredentialsPromise);
|
|
13
13
|
files.set("xs-app.json", xsAppJson);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import AppVariant from "../
|
|
2
|
-
import BaseApp from "../
|
|
1
|
+
import AppVariant from "../appVariant.js";
|
|
2
|
+
import BaseApp from "../baseApp.js";
|
|
3
3
|
import { IConfiguration } from "../model/configuration.js";
|
|
4
|
+
import { UI5BuilderTools } from "../model/types.js";
|
|
5
|
+
import IRepository from "../repositories/repository.js";
|
|
4
6
|
import { IAdapter } from "./adapter.js";
|
|
5
|
-
import
|
|
7
|
+
import CFAdapter from "./cfAdapter.js";
|
|
8
|
+
import { AdaptCommandChain, PostCommandChain, SetupCommandChain } from "./commands/command.js";
|
|
6
9
|
export default class PreviewAdapter implements IAdapter {
|
|
10
|
+
private configuration;
|
|
7
11
|
private cfAdapter;
|
|
8
|
-
|
|
12
|
+
private fetchPreviewResourcesCommand;
|
|
13
|
+
private fetchEndpointsCommand;
|
|
14
|
+
constructor(configuration: IConfiguration, cfAdapter?: CFAdapter);
|
|
15
|
+
createSetupCommandChain(appId: string, repository: IRepository): SetupCommandChain;
|
|
9
16
|
createAdaptCommandChain(baseApp: BaseApp, appVariant: AppVariant): AdaptCommandChain;
|
|
10
|
-
|
|
11
|
-
createPostCommandChain(): PostCommandChain;
|
|
17
|
+
createPostCommandChain(references: Map<string, string>, adaptationProject: AppVariant, ui5BuilderTools: UI5BuilderTools): PostCommandChain;
|
|
12
18
|
}
|
|
@@ -1,17 +1,38 @@
|
|
|
1
|
+
import { dependsOn, getCommonPostCommands } from "./adapter.js";
|
|
1
2
|
import CFAdapter from "./cfAdapter.js";
|
|
3
|
+
import { PostCommandChain, SetupCommandChain } from "./commands/command.js";
|
|
4
|
+
import FetchEndpointsCommand from "./commands/fetchEndpointsCommand.js";
|
|
5
|
+
import FetchPreviewResourcesCommand from "./commands/fetchPreviewResourcesCommand.js";
|
|
6
|
+
import ProcessPreviewResourcesCommand from "./commands/processPreviewResourcesCommand.js";
|
|
7
|
+
import XsAppJsonEnhanceRoutesCommand from "./commands/xsAppJsonEnhanceRoutesCommand.js";
|
|
2
8
|
export default class PreviewAdapter {
|
|
9
|
+
configuration;
|
|
3
10
|
cfAdapter;
|
|
4
|
-
|
|
5
|
-
|
|
11
|
+
fetchPreviewResourcesCommand = null;
|
|
12
|
+
fetchEndpointsCommand = null;
|
|
13
|
+
constructor(configuration, cfAdapter) {
|
|
14
|
+
this.configuration = configuration;
|
|
15
|
+
this.cfAdapter = cfAdapter ?? new CFAdapter(configuration);
|
|
16
|
+
}
|
|
17
|
+
createSetupCommandChain(appId, repository) {
|
|
18
|
+
this.fetchPreviewResourcesCommand = new FetchPreviewResourcesCommand(appId, repository);
|
|
19
|
+
this.fetchEndpointsCommand = new FetchEndpointsCommand(this.configuration);
|
|
20
|
+
return new SetupCommandChain([
|
|
21
|
+
this.fetchPreviewResourcesCommand,
|
|
22
|
+
this.fetchEndpointsCommand
|
|
23
|
+
]);
|
|
6
24
|
}
|
|
7
25
|
createAdaptCommandChain(baseApp, appVariant) {
|
|
8
26
|
return this.cfAdapter.createAdaptCommandChain(baseApp, appVariant);
|
|
9
27
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
28
|
+
createPostCommandChain(references, adaptationProject, ui5BuilderTools) {
|
|
29
|
+
const serviceCredentialsPromise = dependsOn(this.fetchEndpointsCommand);
|
|
30
|
+
const previewPromise = dependsOn(this.fetchPreviewResourcesCommand);
|
|
31
|
+
return new PostCommandChain([
|
|
32
|
+
new ProcessPreviewResourcesCommand(serviceCredentialsPromise, previewPromise),
|
|
33
|
+
new XsAppJsonEnhanceRoutesCommand(serviceCredentialsPromise),
|
|
34
|
+
...getCommonPostCommands(references, adaptationProject, ui5BuilderTools)
|
|
35
|
+
]);
|
|
15
36
|
}
|
|
16
37
|
}
|
|
17
38
|
//# sourceMappingURL=previewAdapter.js.map
|
|
@@ -22,7 +22,7 @@ export default class AbapAnnotationManager {
|
|
|
22
22
|
const i18nManager = new I18nManager(modelName, appVariantId, languages);
|
|
23
23
|
const serviceRequestor = new ServiceRequestor(this.configuration, this.repository);
|
|
24
24
|
const dataSourceManager = new DataSourceManager();
|
|
25
|
-
dataSourceManager.addDataSources(baseAppManifest["sap.app"]?.dataSources);
|
|
25
|
+
await dataSourceManager.addDataSources(baseAppManifest["sap.app"]?.dataSources);
|
|
26
26
|
const annotationFiles = await dataSourceManager.createAnnotationFiles(languages, i18nManager, serviceRequestor);
|
|
27
27
|
const i18nFiles = i18nManager.createFiles(i18nPathName);
|
|
28
28
|
if (i18nManager.hasTranslations()) {
|
|
@@ -3,10 +3,11 @@ import Language from "../../model/language.js";
|
|
|
3
3
|
import ServiceRequestor from "../serviceRequestor.js";
|
|
4
4
|
export default class DataSourceManager {
|
|
5
5
|
private dataSources;
|
|
6
|
+
private shouldDownload;
|
|
6
7
|
/**
|
|
7
8
|
* Parses dataSources from manifest.json.
|
|
8
9
|
* @param dataSourcesJson manifest.json/sap.app/dataSources node
|
|
9
10
|
*/
|
|
10
|
-
addDataSources(dataSourcesJson: any): void
|
|
11
|
+
addDataSources(dataSourcesJson: any): Promise<void>;
|
|
11
12
|
createAnnotationFiles(languages: Language[], i18nManager: I18nManager, serviceRequestor: ServiceRequestor): Promise<Map<string, string>>;
|
|
12
13
|
}
|
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
import DataSourceOData from "./dataSourceOData.js";
|
|
2
1
|
import DataSourceODataAnnotation from "./dataSourceODataAnnotation.js";
|
|
3
2
|
import path from "path/posix";
|
|
4
3
|
export default class DataSourceManager {
|
|
5
4
|
dataSources = new Array();
|
|
5
|
+
shouldDownload(dataSource, type) {
|
|
6
|
+
// is remote service, not local file
|
|
7
|
+
return dataSource.uri?.startsWith("/") &&
|
|
8
|
+
// no local metadata file and wasn't downloaded yet
|
|
9
|
+
!dataSource.settings?.ignoreAnnotationsFromMetadata &&
|
|
10
|
+
dataSource.type === type;
|
|
11
|
+
}
|
|
6
12
|
/**
|
|
7
13
|
* Parses dataSources from manifest.json.
|
|
8
14
|
* @param dataSourcesJson manifest.json/sap.app/dataSources node
|
|
9
15
|
*/
|
|
10
|
-
addDataSources(dataSourcesJson) {
|
|
16
|
+
async addDataSources(dataSourcesJson) {
|
|
11
17
|
if (!dataSourcesJson) {
|
|
12
18
|
return;
|
|
13
19
|
}
|
|
14
20
|
const odataAnnotationMap = new Map();
|
|
21
|
+
const dataSourceODataEntries = Object.entries(dataSourcesJson).filter(([, dataSource]) => dataSource.uri?.startsWith("/") && dataSource.type === "OData");
|
|
22
|
+
const { default: DataSourceOData } = await import("./dataSourceOData.js");
|
|
15
23
|
// Loop over OData first to collect linked annotation names
|
|
16
|
-
for (const [name, dataSource] of
|
|
17
|
-
if (
|
|
24
|
+
for (const [name, dataSource] of dataSourceODataEntries) {
|
|
25
|
+
if (this.shouldDownload(dataSource, "OData")) {
|
|
18
26
|
const uri = path.normalize(dataSource.uri + "/$metadata");
|
|
19
27
|
const odata = new DataSourceOData(name, uri, dataSource);
|
|
20
28
|
odata.getAnnotations().forEach(annotation => odataAnnotationMap.set(annotation, uri));
|
|
@@ -23,10 +31,11 @@ export default class DataSourceManager {
|
|
|
23
31
|
}
|
|
24
32
|
// If ODataAnnotation is in OData annotations, pass metadata url to it
|
|
25
33
|
for (const [name, dataSource] of Object.entries(dataSourcesJson)) {
|
|
26
|
-
const uri = dataSource.uri;
|
|
27
34
|
const metadataUrl = odataAnnotationMap.get(name);
|
|
28
|
-
if (
|
|
29
|
-
|
|
35
|
+
if (this.shouldDownload(dataSource, "ODataAnnotation")) {
|
|
36
|
+
const uri = dataSource.uri;
|
|
37
|
+
const odata = new DataSourceODataAnnotation(name, uri, dataSource, metadataUrl);
|
|
38
|
+
this.dataSources.push(odata);
|
|
30
39
|
}
|
|
31
40
|
}
|
|
32
41
|
for (const dataSource of this.dataSources) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IChange } from "./model/types.js";
|
|
2
|
-
import TaskUtil from "@ui5/project/build/helpers/TaskUtil";
|
|
3
2
|
export default class AppVariant {
|
|
4
3
|
readonly files: ReadonlyMap<string, string>;
|
|
5
4
|
readonly resources?: ReadonlyArray<Resource>;
|
|
@@ -8,7 +7,7 @@ export default class AppVariant {
|
|
|
8
7
|
readonly layer: any;
|
|
9
8
|
readonly content: any;
|
|
10
9
|
prefix: string;
|
|
11
|
-
|
|
10
|
+
movedFiles: Map<string, string>;
|
|
12
11
|
private renaming;
|
|
13
12
|
static fromWorkspace(workspace: IWorkspace, projectNamespace: string): Promise<AppVariant>;
|
|
14
13
|
static fromFiles(files: ReadonlyMap<string, string>): AppVariant;
|
|
@@ -20,13 +19,7 @@ export default class AppVariant {
|
|
|
20
19
|
*/
|
|
21
20
|
getRenamingForMovedFiles(): Map<string, string>;
|
|
22
21
|
getProcessedManifestChanges(): IChange[];
|
|
22
|
+
private sortByTimeStamp;
|
|
23
23
|
private validateManifest;
|
|
24
24
|
private updateRelativePaths;
|
|
25
|
-
/**
|
|
26
|
-
* 3p. We not only omit files, which were moved or deleted from the resulted
|
|
27
|
-
* file set, but also update existing adaptation project resources with
|
|
28
|
-
* renamed content, otherwise flexibility-bundle will contain not renamed
|
|
29
|
-
* content of files.
|
|
30
|
-
*/
|
|
31
|
-
omitDeletedResources(files: ReadonlyMap<string, string>, projectNamespace: string, taskUtil: TaskUtil): void;
|
|
32
25
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { dotToUnderscore, isManifestChange } from "./util/commonUtil.js";
|
|
2
|
-
import
|
|
3
|
-
import ResourceUtil from "./util/resourceUtil.js";
|
|
2
|
+
import ResourceUtil, { TEXT_EXTENSIONS } from "./util/resourceUtil.js";
|
|
4
3
|
import { posix as path } from "path";
|
|
5
4
|
import { moveFile, moveFiles } from "./util/movingHandler/changeFileMoveHandler.js";
|
|
5
|
+
import RenameFilesCommand from "./adapters/commands/renameFilesCommand.js";
|
|
6
|
+
import { validateAppId } from "./util/validator/validator.js";
|
|
6
7
|
const CHANGES_EXT = ".change";
|
|
7
8
|
export default class AppVariant {
|
|
8
9
|
files;
|
|
@@ -15,7 +16,7 @@ export default class AppVariant {
|
|
|
15
16
|
movedFiles = new Map();
|
|
16
17
|
renaming = new Map();
|
|
17
18
|
static async fromWorkspace(workspace, projectNamespace) {
|
|
18
|
-
const EXTENSIONS_TO_PROCESS = "
|
|
19
|
+
const EXTENSIONS_TO_PROCESS = Array.from(TEXT_EXTENSIONS).join(",");
|
|
19
20
|
const resources = await workspace.byGlob(`/**/*.{${EXTENSIONS_TO_PROCESS}}`);
|
|
20
21
|
const files = await ResourceUtil.toFileMap(resources, projectNamespace);
|
|
21
22
|
return new AppVariant(files, resources);
|
|
@@ -34,6 +35,7 @@ export default class AppVariant {
|
|
|
34
35
|
const { reference, id, layer, content } = JSON.parse(manifestString);
|
|
35
36
|
this.reference = reference;
|
|
36
37
|
this.id = id;
|
|
38
|
+
validateAppId(id);
|
|
37
39
|
this.layer = layer;
|
|
38
40
|
this.content = content;
|
|
39
41
|
// Prefix is a subfolder for the app variant to store js, fragments,
|
|
@@ -45,7 +47,8 @@ export default class AppVariant {
|
|
|
45
47
|
const { files, renamingPaths } = moveFiles(this.files, this.prefix, this.id);
|
|
46
48
|
// Directly rename files that with new paths, this ensures no conflict in further renaming
|
|
47
49
|
// In later remaming it's not possible to find correct prefix of moved files
|
|
48
|
-
|
|
50
|
+
new RenameFilesCommand(renamingPaths).execute(files);
|
|
51
|
+
return files;
|
|
49
52
|
}
|
|
50
53
|
;
|
|
51
54
|
/**
|
|
@@ -75,13 +78,20 @@ export default class AppVariant {
|
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
});
|
|
78
|
-
changeFileChanges.sort(
|
|
81
|
+
changeFileChanges.sort(this.sortByTimeStamp);
|
|
79
82
|
manifestChanges.push(...changeFileChanges);
|
|
80
83
|
if (this.layer) {
|
|
81
84
|
manifestChanges.forEach(change => change.layer = this.layer ?? change.layer);
|
|
82
85
|
}
|
|
83
86
|
return manifestChanges;
|
|
84
87
|
}
|
|
88
|
+
sortByTimeStamp(a, b) {
|
|
89
|
+
if (a.creation < b.creation)
|
|
90
|
+
return -1;
|
|
91
|
+
if (a.creation > b.creation)
|
|
92
|
+
return 1;
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
85
95
|
validateManifest(manifest) {
|
|
86
96
|
if (!manifest) {
|
|
87
97
|
throw new Error("Adaptation project should contain manifest.appdescr_variant");
|
|
@@ -98,27 +108,5 @@ export default class AppVariant {
|
|
|
98
108
|
}
|
|
99
109
|
}
|
|
100
110
|
}
|
|
101
|
-
/**
|
|
102
|
-
* 3p. We not only omit files, which were moved or deleted from the resulted
|
|
103
|
-
* file set, but also update existing adaptation project resources with
|
|
104
|
-
* renamed content, otherwise flexibility-bundle will contain not renamed
|
|
105
|
-
* content of files.
|
|
106
|
-
*/
|
|
107
|
-
omitDeletedResources(files, projectNamespace, taskUtil) {
|
|
108
|
-
if (!this.resources) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
for (const resource of this.resources) {
|
|
112
|
-
const relativePath = ResourceUtil.relativeToRoot(resource.getPath(), projectNamespace);
|
|
113
|
-
if (!files.has(relativePath)) {
|
|
114
|
-
taskUtil.setTag(resource, taskUtil.STANDARD_TAGS.OmitFromBuildResult, true);
|
|
115
|
-
if (this.movedFiles.has(relativePath)) {
|
|
116
|
-
const newPath = this.movedFiles.get(relativePath);
|
|
117
|
-
const renamedContent = files.get(newPath);
|
|
118
|
-
resource.setString(renamedContent);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
111
|
}
|
|
124
|
-
//# sourceMappingURL=
|
|
112
|
+
//# sourceMappingURL=appVariant.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { trimExtension } from "./util/commonUtil.js";
|
|
2
|
+
import { validateAppId } from "./util/validator/validator.js";
|
|
2
3
|
const IGNORE_FILES = [
|
|
3
4
|
"manifest-bundle.zip",
|
|
4
5
|
"Component-preload.js",
|
|
@@ -72,22 +73,15 @@ export default class BaseApp {
|
|
|
72
73
|
}
|
|
73
74
|
return "i18n/i18n";
|
|
74
75
|
}
|
|
75
|
-
VALIDATION_RULES = new Map([["sap.app/id",
|
|
76
|
-
if (!value.includes(".")) {
|
|
77
|
-
// https://help.sap.com/docs/bas/developing-sap-fiori-app-in-sap-business-application-studio/releasing-sap-fiori-application-to-be-extensible-in-adaptation-projects-on-sap-s-4hana-cloud
|
|
78
|
-
// In the manifest.json file, make sure that the attribute
|
|
79
|
-
// sap.app/id has at least 2 segments.
|
|
80
|
-
throw new Error(`The original application id '${value}' should consist of multiple segments split by dot, e.g.: original.id`);
|
|
81
|
-
}
|
|
82
|
-
}]]);
|
|
76
|
+
VALIDATION_RULES = new Map([["sap.app/id", validateAppId]]);
|
|
83
77
|
validateProperty(value, property) {
|
|
84
78
|
if (!value) {
|
|
85
79
|
throw new Error(`Original application manifest should have ${property}`);
|
|
86
80
|
}
|
|
87
|
-
let
|
|
88
|
-
if (
|
|
89
|
-
|
|
81
|
+
let validationRule = this.VALIDATION_RULES.get(property);
|
|
82
|
+
if (validationRule) {
|
|
83
|
+
validationRule(value);
|
|
90
84
|
}
|
|
91
85
|
}
|
|
92
86
|
}
|
|
93
|
-
//# sourceMappingURL=
|
|
87
|
+
//# sourceMappingURL=baseApp.js.map
|