@ui5/task-adaptation 1.6.5-rc.3 → 1.6.5
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/.env.test +1 -0
- package/CHANGELOG.md +10 -57
- package/README.md +4 -0
- 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 +102 -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 +51 -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/{appVariantManager.d.ts → appVariant.d.ts} +2 -9
- package/dist/{appVariantManager.js → appVariant.js} +14 -26
- package/dist/{baseAppManager.js → baseApp.js} +6 -12
- package/dist/bundle.js +53 -12
- package/dist/cache/cacheHolder.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +34 -69
- package/dist/model/configuration.d.ts +1 -0
- package/dist/model/configuration.js +1 -0
- package/dist/model/types.d.ts +9 -2
- package/dist/repositories/localRepository.d.ts +2 -3
- package/dist/repositories/localRepository.js +54 -33
- 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 +1 -2
- package/dist/util/fsUtil.js +12 -33
- package/dist/util/renamingUtil.js +1 -1
- package/dist/util/resourceUtil.js +1 -1
- package/dist/util/validator/abapValidator.js +2 -2
- package/dist/util/validator/validator.d.ts +1 -0
- package/dist/util/validator/validator.js +11 -0
- package/package.json +11 -12
- package/.hyperspace/pull_request_bot.json +0 -19
- package/dist/previewManager.d.ts +0 -14
- package/dist/previewManager.js +0 -147
- 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,102 @@
|
|
|
1
|
+
import FsUtil from "../../util/fsUtil.js";
|
|
2
|
+
import { posix as path } from "path";
|
|
3
|
+
import { SetupCommand } from "./command.js";
|
|
4
|
+
import { getLogger } from "@ui5/logger";
|
|
5
|
+
import { REUSE_DIR } from "../../model/configuration.js";
|
|
6
|
+
const log = getLogger("@ui5/task-adaptation::FetchPreviewResourcesCommand");
|
|
7
|
+
export default class FetchPreviewResourcesCommand extends SetupCommand {
|
|
8
|
+
appId;
|
|
9
|
+
repository;
|
|
10
|
+
result = Promise.resolve(undefined);
|
|
11
|
+
constructor(appId, repository) {
|
|
12
|
+
super();
|
|
13
|
+
this.appId = appId;
|
|
14
|
+
this.repository = repository;
|
|
15
|
+
}
|
|
16
|
+
async execute() {
|
|
17
|
+
this.result = this.preparePreview();
|
|
18
|
+
}
|
|
19
|
+
async preparePreview() {
|
|
20
|
+
let ui5AppInfo = "";
|
|
21
|
+
try {
|
|
22
|
+
ui5AppInfo = await FsUtil.readInProject("ui5AppInfo.json", "utf-8");
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
throw new Error(`ui5AppInfo.json is missing in project root, cannot process preview resources: ${error instanceof Error ? error.message : String(error)}`);
|
|
26
|
+
}
|
|
27
|
+
// If no ui5AppInfo is provided, no preview processing is needed
|
|
28
|
+
if (!ui5AppInfo) {
|
|
29
|
+
log.verbose("No ui5AppInfo provided, skipping preview resources processing.");
|
|
30
|
+
return new Map();
|
|
31
|
+
}
|
|
32
|
+
const appInfo = JSON.parse(ui5AppInfo)[this.appId];
|
|
33
|
+
if (!appInfo) {
|
|
34
|
+
throw new Error(`No app info found for original app id '${this.appId}' in ui5AppInfo.json`);
|
|
35
|
+
}
|
|
36
|
+
this.printMessages(appInfo.messages);
|
|
37
|
+
const reuseLibs = appInfo.asyncHints.libs.filter(lib => lib.html5AppHostId && lib.html5AppName && lib.html5AppVersion);
|
|
38
|
+
if (reuseLibs.length > 0) {
|
|
39
|
+
return this.preReadLibs(reuseLibs, this.repository);
|
|
40
|
+
}
|
|
41
|
+
log.verbose("No reuse libraries defined in ui5AppInfo.json for preview");
|
|
42
|
+
return new Map();
|
|
43
|
+
}
|
|
44
|
+
printMessages(appInfoMessages) {
|
|
45
|
+
const logMap = {
|
|
46
|
+
Error: log.error,
|
|
47
|
+
Warning: log.warning,
|
|
48
|
+
Info: log.info,
|
|
49
|
+
debug: log.verbose
|
|
50
|
+
};
|
|
51
|
+
appInfoMessages.forEach((message) => {
|
|
52
|
+
const logger = logMap[message.severity] || log.info;
|
|
53
|
+
logger(`ui5AppInfo.json: ${message.severity} Message: ${message.message} (Error Code: ${message.errorCode})`);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
preReadLibs(reuseLibs, repository) {
|
|
57
|
+
const promises = new Map();
|
|
58
|
+
reuseLibs.forEach(lib => {
|
|
59
|
+
log.info(`Downloading reuse library '${lib.html5AppName}' version '${lib.html5AppVersion}'`);
|
|
60
|
+
const resource = {
|
|
61
|
+
appName: lib.html5AppName,
|
|
62
|
+
appVersion: lib.html5AppVersion,
|
|
63
|
+
appHostId: lib.html5AppHostId,
|
|
64
|
+
cacheBusterToken: Promise.resolve(lib.html5CacheBusterToken)
|
|
65
|
+
};
|
|
66
|
+
const promise = repository
|
|
67
|
+
.fetch(resource)
|
|
68
|
+
.then((libFiles) => this.moveLibraryFiles(libFiles, lib.html5AppName, lib.name));
|
|
69
|
+
promises.set(lib.html5AppName, promise);
|
|
70
|
+
});
|
|
71
|
+
return promises;
|
|
72
|
+
}
|
|
73
|
+
moveLibraryFiles(inputFiles, libraryName, libId) {
|
|
74
|
+
const files = new Map();
|
|
75
|
+
inputFiles.forEach((content, filename) => {
|
|
76
|
+
const newFilename = path.join(libraryName, filename);
|
|
77
|
+
// Source path in xs-app.json needs to be adjusted to new location
|
|
78
|
+
if (filename.includes("xs-app.json")) {
|
|
79
|
+
content = this.modifyRoutes(content, libraryName, libId);
|
|
80
|
+
}
|
|
81
|
+
files.set(newFilename, content);
|
|
82
|
+
});
|
|
83
|
+
return files;
|
|
84
|
+
}
|
|
85
|
+
;
|
|
86
|
+
modifyRoutes(xsAppJson, libName, libId) {
|
|
87
|
+
const xsApp = JSON.parse(xsAppJson);
|
|
88
|
+
xsApp.routes = xsApp.routes.map((route) => {
|
|
89
|
+
route.source = route.source.replace(new RegExp("^\\^\\/?(resources/)?"), `^/resources/${libId.replaceAll(".", "/")}/`);
|
|
90
|
+
if (route.service === "html5-apps-repo-rt") {
|
|
91
|
+
route = {
|
|
92
|
+
source: route.source,
|
|
93
|
+
target: route.target,
|
|
94
|
+
localDir: [REUSE_DIR, libName].join("/")
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return route;
|
|
98
|
+
});
|
|
99
|
+
return JSON.stringify(xsApp);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=fetchPreviewResourcesCommand.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PostCommand } from "./command.js";
|
|
2
|
+
export default class FilterFilesCommand extends PostCommand {
|
|
3
|
+
async execute(files) {
|
|
4
|
+
const IGNORE_FILES = ["manifest.appdescr_variant"];
|
|
5
|
+
const shouldIgnore = (filename, content) => {
|
|
6
|
+
if (filename.endsWith(".change")) {
|
|
7
|
+
return JSON.parse(content).changeType?.startsWith("appdescr_"); // validate JSON
|
|
8
|
+
}
|
|
9
|
+
return IGNORE_FILES.includes(filename);
|
|
10
|
+
};
|
|
11
|
+
const toDelete = [];
|
|
12
|
+
for (const [filename, content] of files) {
|
|
13
|
+
if (shouldIgnore(filename, content)) {
|
|
14
|
+
toDelete.push(filename);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
for (const filename of toDelete) {
|
|
18
|
+
files.delete(filename);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=filterFilesCommand.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import TaskUtil from "@ui5/project/build/helpers/TaskUtil";
|
|
2
|
+
import { PostCommand } from "./command.js";
|
|
3
|
+
export default class OmitDeletedResourcesCommand extends PostCommand {
|
|
4
|
+
private taskUtil;
|
|
5
|
+
private movedFiles;
|
|
6
|
+
private resources;
|
|
7
|
+
private projectNamespace;
|
|
8
|
+
constructor(taskUtil: TaskUtil, movedFiles: Map<string, string>, resources: ReadonlyArray<Resource> | undefined, projectNamespace: string);
|
|
9
|
+
execute(files: Map<string, string>): Promise<void>;
|
|
10
|
+
}
|
|
@@ -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,51 @@
|
|
|
1
|
+
import { PostCommand } from "./command.js";
|
|
2
|
+
import { getLogger } from "@ui5/logger";
|
|
3
|
+
import { 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
|
+
import XsAppJsonEnhanceRoutesCommand from "./xsAppJsonEnhanceRoutesCommand.js";
|
|
7
|
+
const log = getLogger("@ui5/task-adaptation::ProcessPreviewResourcesCommand");
|
|
8
|
+
export default class ProcessPreviewResourcesCommand extends PostCommand {
|
|
9
|
+
serviceCredentialsPromise;
|
|
10
|
+
previewPromise;
|
|
11
|
+
constructor(serviceCredentialsPromise, previewPromise) {
|
|
12
|
+
super();
|
|
13
|
+
this.serviceCredentialsPromise = serviceCredentialsPromise;
|
|
14
|
+
this.previewPromise = previewPromise;
|
|
15
|
+
}
|
|
16
|
+
async execute(files) {
|
|
17
|
+
log.verbose(`Downloading reuse libraries to reuse folder`);
|
|
18
|
+
const baseAppXsAppJson = files.get(XSAPP_JSON_FILENAME);
|
|
19
|
+
const mergedFiles = await this.collectReuseLibFiles(await this.previewPromise, baseAppXsAppJson);
|
|
20
|
+
new XsAppJsonEnhanceRoutesCommand(this.serviceCredentialsPromise).execute(mergedFiles);
|
|
21
|
+
if (mergedFiles.size === 0) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
await ResourceUtil.writeInProject(REUSE_DIR, mergedFiles);
|
|
25
|
+
}
|
|
26
|
+
async collectReuseLibFiles(fetchLibsPromises, mergedXsAppJson) {
|
|
27
|
+
const mergedFiles = new Map();
|
|
28
|
+
if (!fetchLibsPromises) {
|
|
29
|
+
log.verbose("No reuse libraries defined in ui5AppInfo.json for preview");
|
|
30
|
+
return mergedFiles;
|
|
31
|
+
}
|
|
32
|
+
for (const [libName, libFilesPromise] of fetchLibsPromises) {
|
|
33
|
+
const libFiles = await libFilesPromise;
|
|
34
|
+
if (!libFiles || libFiles.size === 0) {
|
|
35
|
+
log.warn(`No files found in reuse library ${libName} for preview`);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
for (const [filename, content] of libFiles) {
|
|
39
|
+
if (filename.endsWith(XSAPP_JSON_FILENAME)) {
|
|
40
|
+
mergedXsAppJson = mergedXsAppJson ? merge([content, mergedXsAppJson]) : content;
|
|
41
|
+
}
|
|
42
|
+
mergedFiles.set(filename, content);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (mergedXsAppJson) {
|
|
46
|
+
mergedFiles.set(XSAPP_JSON_FILENAME, mergedXsAppJson);
|
|
47
|
+
}
|
|
48
|
+
return mergedFiles;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# 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
|
|
@@ -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 FilesUtil from "./util/filesUtil.js";
|
|
3
2
|
import ResourceUtil 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;
|
|
@@ -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
|