@ui5/task-adaptation 1.6.1 → 1.6.3
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 +10 -2
- package/dist/adapters/abapAdapter.js +3 -12
- package/dist/adapters/adapter.d.ts +3 -1
- package/dist/adapters/adapter.js +15 -1
- package/dist/adapters/cfAdapter.js +3 -12
- package/dist/adapters/commands/command.d.ts +3 -8
- package/dist/adapters/commands/command.js +5 -7
- package/dist/adapters/commands/xsAppJsonEnhanceRoutesCommand.js +5 -24
- package/dist/adapters/previewAdapter.d.ts +9 -3
- package/dist/adapters/previewAdapter.js +12 -3
- package/dist/index.js +2 -2
- package/dist/previewManager.d.ts +3 -2
- package/dist/previewManager.js +11 -11
- package/dist/util/cf/xsAppJsonUtil.d.ts +2 -1
- package/dist/util/cf/xsAppJsonUtil.js +19 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,10 +2,16 @@
|
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
4
4
|
|
|
5
|
-
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task-adaptation/compare/v1.6.
|
|
5
|
+
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task-adaptation/compare/v1.6.3...HEAD).
|
|
6
|
+
|
|
7
|
+
<a name="v1.6.3"></a>
|
|
8
|
+
## [v1.6.3] - 2026-03-18
|
|
9
|
+
|
|
10
|
+
<a name="v1.6.2"></a>
|
|
11
|
+
## [v1.6.2] - 2026-03-16
|
|
6
12
|
|
|
7
13
|
<a name="v1.6.1"></a>
|
|
8
|
-
## [v1.6.1] -
|
|
14
|
+
## [v1.6.1] - 2026-02-26
|
|
9
15
|
|
|
10
16
|
<a name="v1.6.0"></a>
|
|
11
17
|
## [v1.6.0] - 2026-02-26
|
|
@@ -143,6 +149,8 @@ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task
|
|
|
143
149
|
<a name="v1.0.0"></a>
|
|
144
150
|
## v1.0.0 - 2020-12-09
|
|
145
151
|
|
|
152
|
+
[v1.6.3]: https://github.com/SAP/ui5-task-adaptation/compare/v1.6.2...v1.6.3
|
|
153
|
+
[v1.6.2]: https://github.com/SAP/ui5-task-adaptation/compare/v1.6.1...v1.6.2
|
|
146
154
|
[v1.6.1]: https://github.com/SAP/ui5-task-adaptation/compare/v1.6.0...v1.6.1
|
|
147
155
|
[v1.6.0]: https://github.com/SAP/ui5-task-adaptation/compare/v0.2.0...v1.6.0
|
|
148
156
|
[v0.2.0]: https://github.com/SAP/ui5-task-adaptation/compare/v0.1.0...v0.2.0
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
+
import { getCommonManifestUpdateCommands } from "./adapter.js";
|
|
1
2
|
import { AdaptCommandChain, ManifestUpdateCommandChain, MergeCommandChain, PostCommandChain } from "./commands/command.js";
|
|
2
|
-
import AddAppVariantIdHierarchyCommand from "./commands/addAppVariantIdHierarchyCommand.js";
|
|
3
|
-
import ApplyDescriptorChangesCommand from "./commands/applyDescriptorChangesCommand.js";
|
|
4
|
-
import SetAppVariantIdCommand from "./commands/setAppVariantIdCommand.js";
|
|
5
|
-
import UpdateComponentNameCommand from "./commands/updateComponentNameCommand.js";
|
|
6
3
|
import DownloadAnnotationsCommand from "./commands/downloadAnnotationsCommand.js";
|
|
7
4
|
import I18nPropertiesMergeCommand from "./commands/i18nPropertiesMergeCommand.js";
|
|
8
|
-
import UpdateCloudDevAdaptationCommand from "./commands/updateCloudDevAdaptationCommand.js";
|
|
9
5
|
export default class AbapAdapter {
|
|
10
6
|
configuration;
|
|
11
7
|
annotationManager;
|
|
@@ -14,7 +10,6 @@ export default class AbapAdapter {
|
|
|
14
10
|
this.annotationManager = annotationManager;
|
|
15
11
|
}
|
|
16
12
|
createAdaptCommandChain(baseApp, appVariant) {
|
|
17
|
-
const manifestChanges = appVariant.getProcessedManifestChanges();
|
|
18
13
|
const appVariantIdHierarchyItem = {
|
|
19
14
|
appVariantId: baseApp.id,
|
|
20
15
|
version: baseApp.version,
|
|
@@ -22,18 +17,14 @@ export default class AbapAdapter {
|
|
|
22
17
|
};
|
|
23
18
|
return new AdaptCommandChain(baseApp.files, [
|
|
24
19
|
new ManifestUpdateCommandChain([
|
|
25
|
-
|
|
26
|
-
new UpdateComponentNameCommand(baseApp.id),
|
|
27
|
-
new ApplyDescriptorChangesCommand(manifestChanges, appVariant.prefix),
|
|
28
|
-
new AddAppVariantIdHierarchyCommand(appVariantIdHierarchyItem),
|
|
29
|
-
new UpdateCloudDevAdaptationCommand(),
|
|
20
|
+
...getCommonManifestUpdateCommands(baseApp, appVariant, appVariantIdHierarchyItem),
|
|
30
21
|
]),
|
|
31
22
|
new DownloadAnnotationsCommand(appVariant.id, appVariant.prefix, this.annotationManager, this.configuration),
|
|
32
23
|
]);
|
|
33
24
|
}
|
|
34
25
|
createMergeCommandChain(baseApp, appVariant) {
|
|
35
26
|
const manifestChanges = appVariant.getProcessedManifestChanges();
|
|
36
|
-
return new MergeCommandChain([
|
|
27
|
+
return new MergeCommandChain(appVariant.getProcessedFiles(), [
|
|
37
28
|
new I18nPropertiesMergeCommand(baseApp.i18nPath, appVariant.prefix, manifestChanges),
|
|
38
29
|
]);
|
|
39
30
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import AppVariant from "../appVariantManager.js";
|
|
2
2
|
import BaseApp from "../baseAppManager.js";
|
|
3
|
-
import {
|
|
3
|
+
import { IAppVariantIdHierarchyManifestItem } from "../model/appVariantIdHierarchyItem.js";
|
|
4
|
+
import { AdaptCommandChain, ManifestUpdateCommand, MergeCommandChain, PostCommandChain } from "./commands/command.js";
|
|
4
5
|
export interface IAdapter {
|
|
5
6
|
createAdaptCommandChain(baseApp: BaseApp, appVariant: AppVariant): AdaptCommandChain;
|
|
6
7
|
createMergeCommandChain(baseApp: BaseApp, appVariant: AppVariant): MergeCommandChain;
|
|
7
8
|
createPostCommandChain(): PostCommandChain;
|
|
8
9
|
}
|
|
10
|
+
export declare function getCommonManifestUpdateCommands(baseApp: BaseApp, appVariant: AppVariant, appVariantIdHierarchyItem: IAppVariantIdHierarchyManifestItem): ManifestUpdateCommand[];
|
package/dist/adapters/adapter.js
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import AddAppVariantIdHierarchyCommand from "./commands/addAppVariantIdHierarchyCommand.js";
|
|
2
|
+
import ApplyDescriptorChangesCommand from "./commands/applyDescriptorChangesCommand.js";
|
|
3
|
+
import SetAppVariantIdCommand from "./commands/setAppVariantIdCommand.js";
|
|
4
|
+
import UpdateCloudDevAdaptationCommand from "./commands/updateCloudDevAdaptationCommand.js";
|
|
5
|
+
import UpdateComponentNameCommand from "./commands/updateComponentNameCommand.js";
|
|
6
|
+
export function getCommonManifestUpdateCommands(baseApp, appVariant, appVariantIdHierarchyItem) {
|
|
7
|
+
const manifestChanges = appVariant.getProcessedManifestChanges();
|
|
8
|
+
return [
|
|
9
|
+
new SetAppVariantIdCommand(appVariant.id),
|
|
10
|
+
new UpdateComponentNameCommand(baseApp.id),
|
|
11
|
+
new ApplyDescriptorChangesCommand(manifestChanges, appVariant.prefix),
|
|
12
|
+
new AddAppVariantIdHierarchyCommand(appVariantIdHierarchyItem),
|
|
13
|
+
new UpdateCloudDevAdaptationCommand(),
|
|
14
|
+
];
|
|
15
|
+
}
|
|
2
16
|
//# sourceMappingURL=adapter.js.map
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
+
import { getCommonManifestUpdateCommands } from "./adapter.js";
|
|
1
2
|
import { AdaptCommandChain, ManifestUpdateCommandChain, MergeCommandChain, PostCommandChain } from "./commands/command.js";
|
|
2
3
|
import XsAppJsonEnhanceRoutesCommand from "./commands/xsAppJsonEnhanceRoutesCommand.js";
|
|
3
|
-
import AddAppVariantIdHierarchyCommand from "./commands/addAppVariantIdHierarchyCommand.js";
|
|
4
|
-
import UpdateCloudDevAdaptationCommand from "./commands/updateCloudDevAdaptationCommand.js";
|
|
5
4
|
import UpdateCloudPlatformCommand from "./commands/updateCloudPlatformCommand.js";
|
|
6
|
-
import ApplyDescriptorChangesCommand from "./commands/applyDescriptorChangesCommand.js";
|
|
7
|
-
import SetAppVariantIdCommand from "./commands/setAppVariantIdCommand.js";
|
|
8
|
-
import UpdateComponentNameCommand from "./commands/updateComponentNameCommand.js";
|
|
9
5
|
import I18nPropertiesMergeCommand from "./commands/i18nPropertiesMergeCommand.js";
|
|
10
6
|
import XsAppJsonMergeCommand from "./commands/xsAppJsonMergeCommand.js";
|
|
11
7
|
export default class CFAdapter {
|
|
@@ -14,25 +10,20 @@ export default class CFAdapter {
|
|
|
14
10
|
this.configuration = configuration;
|
|
15
11
|
}
|
|
16
12
|
createAdaptCommandChain(baseApp, appVariant) {
|
|
17
|
-
const manifestChanges = appVariant.getProcessedManifestChanges();
|
|
18
13
|
const appVariantIdHierarchyItem = {
|
|
19
14
|
appVariantId: baseApp.id,
|
|
20
15
|
version: baseApp.version
|
|
21
16
|
};
|
|
22
17
|
return new AdaptCommandChain(baseApp.files, [
|
|
23
18
|
new ManifestUpdateCommandChain([
|
|
24
|
-
|
|
25
|
-
new UpdateComponentNameCommand(baseApp.id),
|
|
26
|
-
new ApplyDescriptorChangesCommand(manifestChanges, appVariant.prefix),
|
|
27
|
-
new AddAppVariantIdHierarchyCommand(appVariantIdHierarchyItem),
|
|
28
|
-
new UpdateCloudDevAdaptationCommand(),
|
|
19
|
+
...getCommonManifestUpdateCommands(baseApp, appVariant, appVariantIdHierarchyItem),
|
|
29
20
|
new UpdateCloudPlatformCommand(this.configuration.sapCloudService),
|
|
30
21
|
]),
|
|
31
22
|
]);
|
|
32
23
|
}
|
|
33
24
|
createMergeCommandChain(baseApp, appVariant) {
|
|
34
25
|
const manifestChanges = appVariant.getProcessedManifestChanges();
|
|
35
|
-
return new MergeCommandChain([
|
|
26
|
+
return new MergeCommandChain(appVariant.getProcessedFiles(), [
|
|
36
27
|
new I18nPropertiesMergeCommand(baseApp.i18nPath, appVariant.prefix, manifestChanges),
|
|
37
28
|
new XsAppJsonMergeCommand(),
|
|
38
29
|
]);
|
|
@@ -14,8 +14,6 @@ export declare class AdaptCommandChain {
|
|
|
14
14
|
constructor(files: ReadonlyMap<string, string>, commands: AdaptCommand[]);
|
|
15
15
|
/**
|
|
16
16
|
* Executes all commands in the chain that accept the given filename
|
|
17
|
-
* @param files - Map of all files being processed
|
|
18
|
-
* @param filename - The current file being processed
|
|
19
17
|
*/
|
|
20
18
|
execute(): Promise<ReadonlyMap<string, string>>;
|
|
21
19
|
}
|
|
@@ -35,15 +33,14 @@ export declare abstract class MergeCommand {
|
|
|
35
33
|
* It manages a collection of commands and executes them in sequence
|
|
36
34
|
*/
|
|
37
35
|
export declare class MergeCommandChain {
|
|
36
|
+
private appVariantFiles;
|
|
38
37
|
private commands;
|
|
39
|
-
constructor(commands?: MergeCommand[]);
|
|
38
|
+
constructor(appVariantFiles: ReadonlyMap<string, string>, commands?: MergeCommand[]);
|
|
40
39
|
/**
|
|
41
40
|
* Executes all commands in the chain that accept the given filename
|
|
42
41
|
* @param files - Map of all files being processed
|
|
43
|
-
* @param filename - The current file being processed
|
|
44
|
-
* @param appVariantContent - Content from the app variant
|
|
45
42
|
*/
|
|
46
|
-
execute(files: ReadonlyMap<string, string
|
|
43
|
+
execute(files: ReadonlyMap<string, string>): Promise<ReadonlyMap<string, string>>;
|
|
47
44
|
}
|
|
48
45
|
export declare abstract class ManifestUpdateCommand {
|
|
49
46
|
readonly commandType = "manifestUpdate";
|
|
@@ -64,8 +61,6 @@ export declare abstract class PostCommand {
|
|
|
64
61
|
/**
|
|
65
62
|
* Executes the command on the specified file
|
|
66
63
|
* @param files - Map of all files being processed
|
|
67
|
-
* @param filename - The current file being processed
|
|
68
|
-
* @param appVariantContent - Content from the app variant
|
|
69
64
|
*/
|
|
70
65
|
abstract execute(files: Map<string, string>): Promise<void>;
|
|
71
66
|
}
|
|
@@ -10,8 +10,6 @@ export class AdaptCommandChain {
|
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Executes all commands in the chain that accept the given filename
|
|
13
|
-
* @param files - Map of all files being processed
|
|
14
|
-
* @param filename - The current file being processed
|
|
15
13
|
*/
|
|
16
14
|
async execute() {
|
|
17
15
|
const filesCopy = new Map(this.files);
|
|
@@ -33,19 +31,19 @@ export class MergeCommand {
|
|
|
33
31
|
* It manages a collection of commands and executes them in sequence
|
|
34
32
|
*/
|
|
35
33
|
export class MergeCommandChain {
|
|
34
|
+
appVariantFiles;
|
|
36
35
|
commands;
|
|
37
|
-
constructor(commands = []) {
|
|
36
|
+
constructor(appVariantFiles, commands = []) {
|
|
37
|
+
this.appVariantFiles = appVariantFiles;
|
|
38
38
|
this.commands = commands;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Executes all commands in the chain that accept the given filename
|
|
42
42
|
* @param files - Map of all files being processed
|
|
43
|
-
* @param filename - The current file being processed
|
|
44
|
-
* @param appVariantContent - Content from the app variant
|
|
45
43
|
*/
|
|
46
|
-
async execute(files
|
|
44
|
+
async execute(files) {
|
|
47
45
|
const filesCopy = new Map(files);
|
|
48
|
-
for (const [filename, appVariantContent] of appVariantFiles) {
|
|
46
|
+
for (const [filename, appVariantContent] of this.appVariantFiles) {
|
|
49
47
|
const acceptedCommands = this.commands.filter(command => command.accept(filename));
|
|
50
48
|
if (acceptedCommands.length > 0) {
|
|
51
49
|
for (const command of acceptedCommands) {
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import CFUtil from "../../util/cfUtil.js";
|
|
3
|
-
import { getLogger } from "@ui5/logger";
|
|
1
|
+
import { fetchCredentialsAndEnhanceRoutes } from "../../util/cf/xsAppJsonUtil.js";
|
|
4
2
|
import { PostCommand } from "./command.js";
|
|
5
|
-
const log = getLogger("@ui5/task-adaptation::CFProcessor");
|
|
6
3
|
export default class XsAppJsonEnhanceRoutesCommand extends PostCommand {
|
|
7
4
|
configuration;
|
|
8
5
|
constructor(configuration) {
|
|
@@ -10,26 +7,10 @@ export default class XsAppJsonEnhanceRoutesCommand extends PostCommand {
|
|
|
10
7
|
this.configuration = configuration;
|
|
11
8
|
}
|
|
12
9
|
async execute(files) {
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let serviceCredentials;
|
|
18
|
-
try {
|
|
19
|
-
// Get valid service keys with proper endpoints structure
|
|
20
|
-
serviceCredentials = await CFUtil.getOrCreateServiceKeyWithEndpoints(serviceInstanceName, space);
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
throw new Error(`Failed to get valid service keys for app '${this.configuration.appName}': ${error.message}`);
|
|
24
|
-
}
|
|
25
|
-
if (serviceCredentials) {
|
|
26
|
-
const xsAppJson = files.get("xs-app.json");
|
|
27
|
-
if (xsAppJson) {
|
|
28
|
-
files.set("xs-app.json", enhanceRoutesWithEndpointAndService(xsAppJson, serviceCredentials));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
log.info(`No endpoints found for app '${this.configuration.appName}'. xs-app.json will not be updated.`);
|
|
10
|
+
let xsAppJson = files.get("xs-app.json");
|
|
11
|
+
if (xsAppJson) {
|
|
12
|
+
xsAppJson = await fetchCredentialsAndEnhanceRoutes(xsAppJson, this.configuration);
|
|
13
|
+
files.set("xs-app.json", xsAppJson);
|
|
33
14
|
}
|
|
34
15
|
}
|
|
35
16
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import AppVariant from "../appVariantManager.js";
|
|
2
|
+
import BaseApp from "../baseAppManager.js";
|
|
3
|
+
import { IConfiguration } from "../model/configuration.js";
|
|
1
4
|
import { IAdapter } from "./adapter.js";
|
|
2
|
-
import { PostCommandChain } from "./commands/command.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
import { AdaptCommandChain, MergeCommandChain, PostCommandChain } from "./commands/command.js";
|
|
6
|
+
export default class PreviewAdapter implements IAdapter {
|
|
7
|
+
private cfAdapter;
|
|
8
|
+
constructor(configuration: IConfiguration);
|
|
9
|
+
createAdaptCommandChain(baseApp: BaseApp, appVariant: AppVariant): AdaptCommandChain;
|
|
10
|
+
createMergeCommandChain(baseApp: BaseApp, appVariant: AppVariant): MergeCommandChain;
|
|
5
11
|
createPostCommandChain(): PostCommandChain;
|
|
6
12
|
}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import { PostCommandChain } from "./commands/command.js";
|
|
2
1
|
import CFAdapter from "./cfAdapter.js";
|
|
3
|
-
export default class PreviewAdapter
|
|
2
|
+
export default class PreviewAdapter {
|
|
3
|
+
cfAdapter;
|
|
4
|
+
constructor(configuration) {
|
|
5
|
+
this.cfAdapter = new CFAdapter(configuration);
|
|
6
|
+
}
|
|
7
|
+
createAdaptCommandChain(baseApp, appVariant) {
|
|
8
|
+
return this.cfAdapter.createAdaptCommandChain(baseApp, appVariant);
|
|
9
|
+
}
|
|
10
|
+
createMergeCommandChain(baseApp, appVariant) {
|
|
11
|
+
return this.cfAdapter.createMergeCommandChain(baseApp, appVariant);
|
|
12
|
+
}
|
|
4
13
|
createPostCommandChain() {
|
|
5
|
-
return
|
|
14
|
+
return this.cfAdapter.createPostCommandChain();
|
|
6
15
|
}
|
|
7
16
|
}
|
|
8
17
|
//# sourceMappingURL=previewAdapter.js.map
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ export default ({ workspace, options, taskUtil }) => {
|
|
|
16
16
|
const processor = determineProcessor(options.configuration);
|
|
17
17
|
const adapter = processor.getAdapter();
|
|
18
18
|
const adaptationProject = await AppVariant.fromWorkspace(workspace, options.projectNamespace);
|
|
19
|
-
const previewManagerPromise = PreviewManager.createFromRoot(adaptationProject.reference, processor);
|
|
19
|
+
const previewManagerPromise = PreviewManager.createFromRoot(adaptationProject.reference, processor, options.configuration);
|
|
20
20
|
const appVariantIdHierarchy = await processor.getAppVariantIdHierarchy(adaptationProject.reference);
|
|
21
21
|
if (appVariantIdHierarchy.length === 0) {
|
|
22
22
|
throw new Error(`No app variant found for reference ${adaptationProject.reference}`);
|
|
@@ -40,7 +40,7 @@ export default ({ workspace, options, taskUtil }) => {
|
|
|
40
40
|
const adaptCommandChain = adapter.createAdaptCommandChain(baseApp, appVariant);
|
|
41
41
|
const mergeCommandChain = adapter.createMergeCommandChain(baseApp, appVariant);
|
|
42
42
|
const adaptedFiles = await adaptCommandChain.execute();
|
|
43
|
-
const mergedFiles = await mergeCommandChain.execute(adaptedFiles
|
|
43
|
+
const mergedFiles = await mergeCommandChain.execute(adaptedFiles);
|
|
44
44
|
return mergedFiles;
|
|
45
45
|
};
|
|
46
46
|
let files = await fetchFilesPromises.reduce(async (previousFiles, currentFiles) => adapt(await previousFiles, await currentFiles), fetchFilesPromises.shift());
|
package/dist/previewManager.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import IProcessor from "./processors/processor.js";
|
|
2
|
+
import { IConfiguration } from "./model/types.js";
|
|
2
3
|
export default class PreviewManager {
|
|
3
4
|
private readonly fetchLibsPromises;
|
|
4
|
-
|
|
5
|
+
private readonly configuration;
|
|
6
|
+
static createFromRoot(appId: string, processor: IProcessor, configuration: IConfiguration): Promise<PreviewManager>;
|
|
5
7
|
static isPreviewRequested(): boolean;
|
|
6
8
|
private constructor();
|
|
7
9
|
processPreviewResources(baseAppFiles: ReadonlyMap<string, string>): Promise<void>;
|
|
8
10
|
private preReadLibs;
|
|
9
11
|
private searchBaseAppXsAppJsonFile;
|
|
10
|
-
private mergeXsAppJsonFiles;
|
|
11
12
|
private static moveLibraryFiles;
|
|
12
13
|
private static modifyRoutes;
|
|
13
14
|
}
|
package/dist/previewManager.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getLogger } from "@ui5/logger";
|
|
2
2
|
import ResourceUtil from "./util/resourceUtil.js";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { merge } from "./util/cf/xsAppJsonUtil.js";
|
|
4
|
+
import { fetchCredentialsAndEnhanceRoutes, merge } from "./util/cf/xsAppJsonUtil.js";
|
|
5
5
|
import FsUtil from "./util/fsUtil.js";
|
|
6
6
|
const log = getLogger("@ui5/task-adaptation::PreviewManager");
|
|
7
7
|
const REUSE_DIR = ".adp/reuse";
|
|
@@ -9,7 +9,8 @@ const APP_INFO_FILE = "ui5AppInfo.json";
|
|
|
9
9
|
const XS_APP_JSON_FILE = "xs-app.json";
|
|
10
10
|
export default class PreviewManager {
|
|
11
11
|
fetchLibsPromises = new Map();
|
|
12
|
-
|
|
12
|
+
configuration;
|
|
13
|
+
static async createFromRoot(appId, processor, configuration) {
|
|
13
14
|
let ui5AppInfo = "";
|
|
14
15
|
if (PreviewManager.isPreviewRequested()) {
|
|
15
16
|
try {
|
|
@@ -22,12 +23,13 @@ export default class PreviewManager {
|
|
|
22
23
|
else {
|
|
23
24
|
log.verbose("Preview mode not requested (env variable ADP_BUILDER_MODE=preview is not set), skipping preview resources processing.");
|
|
24
25
|
}
|
|
25
|
-
return new PreviewManager(appId, ui5AppInfo, processor);
|
|
26
|
+
return new PreviewManager(appId, ui5AppInfo, processor, configuration);
|
|
26
27
|
}
|
|
27
28
|
static isPreviewRequested() {
|
|
28
29
|
return process.env.ADP_BUILDER_MODE === "preview";
|
|
29
30
|
}
|
|
30
|
-
constructor(appId, ui5AppInfo, processor) {
|
|
31
|
+
constructor(appId, ui5AppInfo, processor, configuration) {
|
|
32
|
+
this.configuration = configuration;
|
|
31
33
|
// If no ui5AppInfo is provided, no preview processing is needed
|
|
32
34
|
if (!ui5AppInfo) {
|
|
33
35
|
log.verbose("No ui5AppInfo provided, skipping preview resources processing.");
|
|
@@ -74,7 +76,11 @@ export default class PreviewManager {
|
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
this.searchBaseAppXsAppJsonFile(xsAppFiles, baseAppFiles);
|
|
77
|
-
|
|
79
|
+
let xsAppJson = merge(xsAppFiles);
|
|
80
|
+
if (xsAppJson) {
|
|
81
|
+
xsAppJson = await fetchCredentialsAndEnhanceRoutes(xsAppJson, this.configuration);
|
|
82
|
+
mergedFiles.set(XS_APP_JSON_FILE, xsAppJson);
|
|
83
|
+
}
|
|
78
84
|
await ResourceUtil.writeInProject(REUSE_DIR, mergedFiles);
|
|
79
85
|
}
|
|
80
86
|
preReadLibs(reuseLibs, processor) {
|
|
@@ -97,12 +103,6 @@ export default class PreviewManager {
|
|
|
97
103
|
log.warn("xs-app.json is missing in the downloaded base app files for preview");
|
|
98
104
|
}
|
|
99
105
|
}
|
|
100
|
-
mergeXsAppJsonFiles(xsAppFiles, files) {
|
|
101
|
-
const mergedXsAppJson = merge(xsAppFiles);
|
|
102
|
-
if (mergedXsAppJson) {
|
|
103
|
-
files.set(XS_APP_JSON_FILE, mergedXsAppJson);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
106
|
static moveLibraryFiles(inputFiles, libraryName, libId) {
|
|
107
107
|
const files = new Map();
|
|
108
108
|
inputFiles.forEach((content, filename) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ServiceCredentials } from "../../model/types.js";
|
|
1
|
+
import { IConfiguration, ServiceCredentials } from "../../model/types.js";
|
|
2
2
|
export declare const XSAPP_JSON_FILENAME = "xs-app.json";
|
|
3
3
|
/**
|
|
4
4
|
* Merges multiple xs-app.json contents into one. AppVariant and Reuse Library
|
|
@@ -11,3 +11,4 @@ export declare const XSAPP_JSON_FILENAME = "xs-app.json";
|
|
|
11
11
|
export declare function merge(xsAppFiles: string[]): string | undefined;
|
|
12
12
|
export declare function enhanceRoutesWithEndpointAndService(xsAppJsonContent: string, serviceCredentials: ServiceCredentials): string;
|
|
13
13
|
export declare function enhanceRoutes(serviceCredentials: ServiceCredentials, baseRoutes: any): any;
|
|
14
|
+
export declare function fetchCredentialsAndEnhanceRoutes(xsAppJson: string, { serviceInstanceName, space, appName }: IConfiguration): Promise<string>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getLogger } from "@ui5/logger";
|
|
2
|
+
import CFUtil from "../cfUtil.js";
|
|
2
3
|
const log = getLogger("@ui5/task-adaptation::XSAppJsonUtil");
|
|
3
4
|
export const XSAPP_JSON_FILENAME = "xs-app.json";
|
|
4
5
|
/**
|
|
@@ -78,4 +79,22 @@ export function enhanceRoutes(serviceCredentials, baseRoutes) {
|
|
|
78
79
|
}
|
|
79
80
|
});
|
|
80
81
|
}
|
|
82
|
+
export async function fetchCredentialsAndEnhanceRoutes(xsAppJson, { serviceInstanceName, space, appName }) {
|
|
83
|
+
if (!serviceInstanceName) {
|
|
84
|
+
throw new Error(`Service instance name must be specified in ui5.yaml configuration for app '${appName}'`);
|
|
85
|
+
}
|
|
86
|
+
let serviceCredentials;
|
|
87
|
+
try {
|
|
88
|
+
// Get valid service keys with proper endpoints structure
|
|
89
|
+
serviceCredentials = await CFUtil.getOrCreateServiceKeyWithEndpoints(serviceInstanceName, space);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
throw new Error(`Failed to get valid service keys for app '${appName}': ${error.message}`);
|
|
93
|
+
}
|
|
94
|
+
if (serviceCredentials) {
|
|
95
|
+
return enhanceRoutesWithEndpointAndService(xsAppJson, serviceCredentials);
|
|
96
|
+
}
|
|
97
|
+
log.info(`No endpoints found for app '${appName}'. xs-app.json will not be updated.`);
|
|
98
|
+
return xsAppJson;
|
|
99
|
+
}
|
|
81
100
|
//# sourceMappingURL=xsAppJsonUtil.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui5/task-adaptation",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
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": {
|
|
@@ -59,7 +59,6 @@
|
|
|
59
59
|
"@types/chai-as-promised": "^7.1.4",
|
|
60
60
|
"@types/js-yaml": "^4.0.3",
|
|
61
61
|
"@types/jsdom": "^21.1.6",
|
|
62
|
-
"@types/lodash": "^4.14.196",
|
|
63
62
|
"@types/mocha": "^9.1.0",
|
|
64
63
|
"@types/semver": "^7.3.8",
|
|
65
64
|
"@types/sinon": "^10.0.16",
|
|
@@ -115,7 +114,8 @@
|
|
|
115
114
|
"src/annotations/transformers/transformer.ts",
|
|
116
115
|
"src/model/configuration.ts",
|
|
117
116
|
"src/model/appVariantIdHierarchyItem.ts",
|
|
118
|
-
"src/adapters/adapter.ts"
|
|
117
|
+
"src/adapters/adapter.ts",
|
|
118
|
+
"src/adapters/previewAdapter.ts"
|
|
119
119
|
],
|
|
120
120
|
"check-coverage": true,
|
|
121
121
|
"statements": 85,
|