Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support multiple services for ui5 yaml files and manifest.json #2455

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3e75124
fix: multiple backends to fiori tools proxy middleware
broksy Oct 11, 2024
3e44986
feat: handle multiple services
broksy Oct 11, 2024
0ff8430
feat: generate mockdatapath
broksy Oct 11, 2024
b8ba6ea
test: generate mockdatapath
broksy Oct 11, 2024
ee194b1
feat: support multiple annotations per service
broksy Oct 15, 2024
c0df67f
fix: type
broksy Oct 15, 2024
c038552
Linting auto fix commit
github-actions[bot] Oct 15, 2024
d17a96f
Merge branch 'main' into feat/supportMultipleServices
broksy Oct 15, 2024
e4f25db
feat: changeset
broksy Oct 15, 2024
05d9498
fix: failing tests and getting of annotation namespaces
broksy Oct 15, 2024
2c06b4f
fix: simplified logic for getting config of mockserver
broksy Oct 16, 2024
1078c8d
Merge branch 'main' into feat/supportMultipleServices
broksy Oct 16, 2024
0d42704
Merge branch 'main' into feat/supportMultipleServices
Klaus-Keller Oct 16, 2024
5162ea3
fix: resolve conflict in i18n instances
Klaus-Keller Oct 16, 2024
6ee0de5
fix: simplified logic for service handling
broksy Oct 17, 2024
a900e7e
fix: snapshot
broksy Oct 17, 2024
9ecd88f
chore: moved overwrite param to mock config object
broksy Oct 17, 2024
19f8b31
fix: generate mockserver config param
broksy Oct 17, 2024
f40bd4f
fix: dynamical paths for services
broksy Oct 17, 2024
7be6a3a
fix: snapshots
broksy Oct 17, 2024
ecd6496
feat: check for service name when generating mockdatapath
broksy Oct 18, 2024
cf343ea
fix: snapshots
broksy Oct 18, 2024
7239c3a
feat: support backward compatibility for annotations as object
broksy Oct 18, 2024
e0e2e94
Linting auto fix commit
github-actions[bot] Oct 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/empty-snakes-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@sap-ux/mockserver-config-writer': minor
'@sap-ux/odata-service-writer': minor
'@sap-ux/ui5-config': minor
'@sap-ux/create': minor
---

Support multiple services and multiple annotations per service.
10 changes: 6 additions & 4 deletions examples/simple-generator/src/app/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ export async function getMetadata(
metadata,
annotations:
annotations?.length > 0
? {
technicalName: annotations[0].TechnicalName,
xml: annotations[0].Definitions
}
? [
{
technicalName: annotations[0].TechnicalName,
xml: annotations[0].Definitions
}
]
: undefined
};
}
11 changes: 7 additions & 4 deletions packages/create/src/cli/add/mockserver-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ async function addMockserverConfig(
);
await validateBasePath(basePath);
const webappPath = await getWebappPath(basePath);
const config: MockserverConfig = { webappPath };
if (interactive) {
const questions = getMockserverConfigQuestions({ webappPath });
config.ui5MockYamlConfig = await prompt(questions);
const config: MockserverConfig = { webappPath, ui5MockYamlConfig: {} };
if (interactive && config.ui5MockYamlConfig) {
const questions = getMockserverConfigQuestions({ webappPath, askForOverwrite: true });
const responses = await prompt(questions);
config.ui5MockYamlConfig.path = responses?.path;
// User response for whether to overwrite existing services in mock-server config
config.ui5MockYamlConfig.overwriteServices = !!responses?.overwrite;
}
const fs = await generateMockserverConfig(basePath, config);
await traceChanges(fs);
Expand Down
43 changes: 42 additions & 1 deletion packages/create/test/unit/cli/add/mockserver-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,48 @@ describe('Test command add mockserver-config', () => {
expect(logLevelSpy).not.toBeCalled();
expect(loggerMock.debug).toBeCalled();
expect(loggerMock.error).not.toBeCalled();
expect(promptSpy).toBeCalledWith([{ webappPath: join(appRoot, 'webapp') }]);
expect(promptSpy).toBeCalledWith([{ webappPath: join(appRoot, 'webapp'), askForOverwrite: true }]);
expect(fsMock.commit).toBeCalled();
expect(spawnSpy).toBeCalled();
});

test('Test create-fiori add mockserver-config <appRoot> --interactive with overwrite option', async () => {
// Mock setup
jest.spyOn(mockserverWriter, 'getMockserverConfigQuestions').mockReturnValue([
{
name: 'path',
type: 'text',
message: 'Path to mocked service'
},
{
type: 'confirm',
name: 'overwrite',
message: 'Overwrite existing services'
}
]);
const promptSpy = jest.spyOn(prompts, 'prompt');

// Test execution
const command = new Command('add');
addAddMockserverConfigCommand(command);
await command.parseAsync(getArgv(['mockserver-config', appRoot, '--interactive']));

// Result check
expect(logLevelSpy).not.toBeCalled();
expect(loggerMock.debug).toBeCalled();
expect(loggerMock.error).not.toBeCalled();
expect(promptSpy).toBeCalledWith([
{
name: 'path',
type: 'text',
message: 'Path to mocked service'
},
{
message: 'Overwrite existing services',
name: 'overwrite',
type: 'confirm'
}
]);
expect(fsMock.commit).toBeCalled();
expect(spawnSpy).toBeCalled();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ server:
mountPath: /
services:
- urlPath: /sap/opu/odata/sap/SEPMRA_ALP_SO_ANA_SRV
metadataPath: ./webapp/localService/metadata.xml
mockdataPath: ./webapp/localService/data
metadataPath: ./webapp/localService/mainService/metadata.xml
mockdataPath: ./webapp/localService/mainService/data
generateMockData: true
annotations: []
",
Expand Down Expand Up @@ -138,8 +138,8 @@ server:
mountPath: /
services:
- urlPath: /sap/opu/odata/sap/SEPMRA_ALP_SO_ANA_SRV
metadataPath: ./webapp/localService/metadata.xml
mockdataPath: ./webapp/localService/data
metadataPath: ./webapp/localService/mainService/metadata.xml
mockdataPath: ./webapp/localService/mainService/data
generateMockData: true
annotations:
- localPath: ./webapp/localService/SEPMRA_PROD_MAN_ANNO_MDL.xml
Expand Down Expand Up @@ -2338,6 +2338,10 @@ xmlns:edmx=\\"http://docs.oasis-open.org/odata/ns/edmx\\">
</edmx:Edmx>",
"state": "modified",
},
"webapp/localService/data/keep": Object {
"contents": "",
"state": "modified",
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not add empty keep files. If a module relies on the fact the folder webapp/localService/data exists, we need to make it more robust.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should generate empty keep files into a project.

"webapp/localService/metadata.xml": Object {
"contents": "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>
<edmx:Edmx xmlns:edmx=\\"http://schemas.microsoft.com/ado/2007/06/edmx\\" xmlns:m=\\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\\" xmlns:sap=\\"http://www.sap.com/Protocols/SAPData\\" Version=\\"1.0\\">
Expand Down Expand Up @@ -6071,8 +6075,8 @@ server:
mountPath: /
services:
- urlPath: /sap/opu/odata4/sap/c_salesordermanage_srv/srvd/sap/c_salesordermanage_sd_aggregate/0001
metadataPath: ./webapp/localService/metadata.xml
mockdataPath: ./webapp/localService/data
metadataPath: ./webapp/localService/mainService/metadata.xml
mockdataPath: ./webapp/localService/mainService/data
generateMockData: true
annotations: []
",
Expand Down Expand Up @@ -6116,8 +6120,8 @@ server:
mountPath: /
services:
- urlPath: /sap/opu/odata4/sap/c_salesordermanage_srv/srvd/sap/c_salesordermanage_sd_aggregate/0001
metadataPath: ./webapp/localService/metadata.xml
mockdataPath: ./webapp/localService/data
metadataPath: ./webapp/localService/mainService/metadata.xml
mockdataPath: ./webapp/localService/mainService/data
generateMockData: true
annotations:
- localPath: ./webapp/annotations/annotation.xml
Expand Down Expand Up @@ -6246,6 +6250,10 @@ appDescription=A Fiori application.",
</html>",
"state": "modified",
},
"webapp/localService/data/keep": Object {
"contents": "",
"state": "modified",
},
"webapp/localService/metadata.xml": Object {
"contents": "<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
<edmx:Edmx Version=\\"4.0\\" xmlns:edmx=\\"http://docs.oasis-open.org/odata/ns/edmx\\">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ server:
mountPath: /
services:
- urlPath: /sap/opu/odata4/dmo/sb_travel_mduu_o4/srvd/dmo/sd_travel_mduu/0001
metadataPath: ./webapp/localService/metadata.xml
mockdataPath: ./webapp/localService/data
metadataPath: ./webapp/localService/mainService/metadata.xml
mockdataPath: ./webapp/localService/mainService/data
generateMockData: true
annotations: []
",
Expand Down Expand Up @@ -135,8 +135,8 @@ server:
mountPath: /
services:
- urlPath: /sap/opu/odata4/dmo/sb_travel_mduu_o4/srvd/dmo/sd_travel_mduu/0001
metadataPath: ./webapp/localService/metadata.xml
mockdataPath: ./webapp/localService/data
metadataPath: ./webapp/localService/mainService/metadata.xml
mockdataPath: ./webapp/localService/mainService/data
generateMockData: true
annotations:
- localPath: ./webapp/annotations/annotation.xml
Expand Down Expand Up @@ -276,6 +276,10 @@ appDescription=A Fiori application.",
</html>",
"state": "modified",
},
"webapp/localService/data/keep": Object {
"contents": "",
"state": "modified",
},
"webapp/localService/metadata.xml": Object {
"contents": "<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
<edmx:Edmx Version=\\"4.0\\" xmlns:edmx=\\"http://docs.oasis-open.org/odata/ns/edmx\\"
Expand Down Expand Up @@ -3815,8 +3819,8 @@ server:
mountPath: /
services:
- urlPath: /sap/opu/odata4/dmo/sb_travel_mduu_o4/srvd/dmo/sd_travel_mduu/0001
metadataPath: ./webapp/localService/metadata.xml
mockdataPath: ./webapp/localService/data
metadataPath: ./webapp/localService/mainService/metadata.xml
mockdataPath: ./webapp/localService/mainService/data
generateMockData: true
annotations: []
builder:
Expand Down Expand Up @@ -3876,8 +3880,8 @@ server:
mountPath: /
services:
- urlPath: /sap/opu/odata4/dmo/sb_travel_mduu_o4/srvd/dmo/sd_travel_mduu/0001
metadataPath: ./webapp/localService/metadata.xml
mockdataPath: ./webapp/localService/data
metadataPath: ./webapp/localService/mainService/metadata.xml
mockdataPath: ./webapp/localService/mainService/data
generateMockData: true
annotations:
- localPath: ./webapp/annotations/annotation.xml
Expand Down Expand Up @@ -4040,6 +4044,10 @@ appDescription=A Fiori application.",
</html>",
"state": "modified",
},
"webapp/localService/data/keep": Object {
"contents": "",
"state": "modified",
},
"webapp/localService/metadata.xml": Object {
"contents": "<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
<edmx:Edmx Version=\\"4.0\\" xmlns:edmx=\\"http://docs.oasis-open.org/odata/ns/edmx\\"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ server:
mountPath: /
services:
- urlPath: /sap/opu/odata4/dmo/sb_travel_mduu_o4/srvd/dmo/sd_travel_mduu/0001
metadataPath: ./webapp/localService/metadata.xml
mockdataPath: ./webapp/localService/data
metadataPath: ./webapp/localService/mainService/metadata.xml
mockdataPath: ./webapp/localService/mainService/data
generateMockData: true
annotations: []
",
Expand Down Expand Up @@ -136,8 +136,8 @@ server:
mountPath: /
services:
- urlPath: /sap/opu/odata4/dmo/sb_travel_mduu_o4/srvd/dmo/sd_travel_mduu/0001
metadataPath: ./webapp/localService/metadata.xml
mockdataPath: ./webapp/localService/data
metadataPath: ./webapp/localService/mainService/metadata.xml
mockdataPath: ./webapp/localService/mainService/data
generateMockData: true
annotations:
- localPath: ./webapp/annotations/annotation.xml
Expand Down Expand Up @@ -326,6 +326,10 @@ MainTitle=Main",
</html>",
"state": "modified",
},
"webapp/localService/data/keep": Object {
"contents": "",
"state": "modified",
},
"webapp/localService/metadata.xml": Object {
"contents": "<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
<edmx:Edmx Version=\\"4.0\\" xmlns:edmx=\\"http://docs.oasis-open.org/odata/ns/edmx\\"
Expand Down Expand Up @@ -3834,8 +3838,8 @@ server:
mountPath: /
services:
- urlPath: /sap/opu/odata4/dmo/sb_travel_mduu_o4/srvd/dmo/sd_travel_mduu/0001
metadataPath: ./webapp/localService/metadata.xml
mockdataPath: ./webapp/localService/data
metadataPath: ./webapp/localService/mainService/metadata.xml
mockdataPath: ./webapp/localService/mainService/data
generateMockData: true
annotations: []
builder:
Expand Down Expand Up @@ -3895,8 +3899,8 @@ server:
mountPath: /
services:
- urlPath: /sap/opu/odata4/dmo/sb_travel_mduu_o4/srvd/dmo/sd_travel_mduu/0001
metadataPath: ./webapp/localService/metadata.xml
mockdataPath: ./webapp/localService/data
metadataPath: ./webapp/localService/mainService/metadata.xml
mockdataPath: ./webapp/localService/mainService/data
generateMockData: true
annotations:
- localPath: ./webapp/annotations/annotation.xml
Expand Down Expand Up @@ -4160,6 +4164,10 @@ MainTitle=Main",
</html>",
"state": "modified",
},
"webapp/localService/data/keep": Object {
"contents": "",
"state": "modified",
},
"webapp/localService/metadata.xml": Object {
"contents": "<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
<edmx:Edmx Version=\\"4.0\\" xmlns:edmx=\\"http://docs.oasis-open.org/odata/ns/edmx\\"
Expand Down
Loading
Loading