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: Multiple service support #2499

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
3c6e5bb
fix: resolve conflict in i18n instances
broksy Oct 24, 2024
b08658e
feat: array support for annotations
broksy Oct 24, 2024
b80ecb3
fix: refactoring
broksy Oct 25, 2024
f74255d
feat: handle services from manifest or generate parameter
broksy Oct 25, 2024
814e77a
feat: changeset
broksy Oct 25, 2024
22440a1
feat: service removal
broksy Oct 25, 2024
0aeecc7
test: backend removal
broksy Oct 25, 2024
3070e73
Linting auto fix commit
github-actions[bot] Oct 25, 2024
a5c6b93
feat: mockserver create command with overwrite option
broksy Oct 25, 2024
43f470c
fix: code smells
broksy Oct 25, 2024
47835f1
fix: duplications for services
broksy Oct 25, 2024
5fa9081
fix: code smells
broksy Oct 25, 2024
14407d4
test: service removal
broksy Oct 25, 2024
7864090
fix: complexity for adding services
broksy Oct 28, 2024
d359abf
chore: naming for service removal
broksy Oct 28, 2024
9375602
feat: mockdata path generation and removal
broksy Oct 28, 2024
f27023e
chore: test describe
broksy Oct 28, 2024
c1bfc01
test: cds generate
broksy Oct 28, 2024
8759444
feat: removal of annotations for cds
broksy Oct 29, 2024
a68d24b
fix: code smells
broksy Oct 29, 2024
e78abdf
Merge branch 'main' into feat/multiple-services
Klaus-Keller Oct 30, 2024
30966ac
fix: snapshots
broksy Oct 31, 2024
462977a
Merge branch 'main' into feat/multiple-services
broksy Oct 31, 2024
56dad86
fix: interactive generatemockserverconfig
broksy Oct 31, 2024
adbd35d
fix: snapshots
broksy Oct 31, 2024
bc00b37
fix: revert changes
broksy Oct 31, 2024
6ad3487
Merge branch 'main' into feat/multiple-services
tobiasqueck Oct 31, 2024
a03d983
chore: only use dataSources config for generating services
broksy Nov 1, 2024
24c4be8
chore: jsdoc
broksy Nov 1, 2024
a93be3d
fix: path separator
broksy Nov 1, 2024
edc8ef4
chore: getting of project yaml files
broksy Nov 1, 2024
7aa3ed5
feat: do not generate empty mock data folder and add optional appRoot…
broksy Nov 4, 2024
1eb31f9
fix: missing optional appRoot
broksy Nov 4, 2024
7896e4b
fix: make dataSources config not optional and update params
broksy Nov 6, 2024
7958134
fix: only add unique services
broksy Nov 6, 2024
698fc4e
Merge branch 'main' into feat/multiple-services
broksy Nov 6, 2024
53cc73e
fix: snapshots
broksy Nov 6, 2024
f863b55
feat: remove annotations along with the service
broksy Nov 7, 2024
77731b1
fix: refactored annotations removal
broksy Nov 7, 2024
33ab01a
fix: replaced snapshots with actual data check
broksy Nov 7, 2024
76c6f64
chore: review comments
broksy Nov 8, 2024
041d98b
fix: simplified removal
broksy Nov 8, 2024
568ded9
fix: removed redundant parameters
broksy Nov 8, 2024
e567979
fix: refactored complex generate function
broksy Nov 8, 2024
db71430
fix: type cast
broksy Nov 8, 2024
72910e6
fix: odata service types
broksy Nov 8, 2024
a9211c3
fix: jsdoc and service comparison by paths
broksy Nov 12, 2024
54a778d
feat: generate metadata file to service folder
broksy Nov 12, 2024
e5029f3
fix(app-modeler): service path
broksy Nov 13, 2024
6da046a
fix: check if first service and if so call it mainService
broksy Nov 13, 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/proud-buses-repeat.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 for multiple services and multiple annotations per service.
3 changes: 2 additions & 1 deletion packages/create/src/cli/add/mockserver-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ async function addMockserverConfig(
const webappPath = await getWebappPath(basePath);
const config: MockserverConfig = { webappPath };
if (interactive) {
const questions = getMockserverConfigQuestions({ webappPath });
const questions = getMockserverConfigQuestions({ webappPath, askForOverwrite: true });
// User responses for webappPath and whether to overwrite existing services in mockserver config
config.ui5MockYamlConfig = await prompt(questions);
}
const fs = await generateMockserverConfig(basePath, config);
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 @@ -105,7 +105,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(execNpmCommandSpy).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 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 services',
name: 'overwrite',
type: 'confirm'
}
]);
expect(fsMock.commit).toBeCalled();
expect(execNpmCommandSpy).toBeCalled();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,14 @@ 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: []
annotations:
- localPath: ./webapp/localService/SEPMRA_PROD_MAN_ANNO_MDL.xml
urlPath: /sap/opu/odata/IWFND/CATALOGSERVICE;v=2/Annotations(TechnicalName='SEPMRA_PROD_MAN_ANNO_MDL',Version='0001')/$value/
- localPath: ./webapp/annotations/annotation.xml
urlPath: annotations/annotation.xml
",
"state": "modified",
},
Expand Down Expand Up @@ -137,8 +141,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 @@ -2337,7 +2341,7 @@ xmlns:edmx=\\"http://docs.oasis-open.org/odata/ns/edmx\\">
</edmx:Edmx>",
"state": "modified",
},
"webapp/localService/metadata.xml": Object {
"webapp/localService/mainService/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\\">
<edmx:Reference xmlns:edmx=\\"http://docs.oasis-open.org/odata/ns/edmx\\" Uri=\\"https://ldai1uia.wdf.sap.corp:44300/sap/opu/odata/iwfnd/catalogservice;v=2/Vocabularies(TechnicalName='%2FIWBEP%2FVOC_COMMON',Version='0001',SAP__Origin='LOCAL')/$value\\">
Expand Down Expand Up @@ -6069,10 +6073,12 @@ 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: []
annotations:
- localPath: ./webapp/annotations/annotation.xml
urlPath: annotations/annotation.xml
",
"state": "modified",
},
Expand Down Expand Up @@ -6114,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 @@ -6244,7 +6250,7 @@ appDescription=A Fiori application.",
</html>",
"state": "modified",
},
"webapp/localService/metadata.xml": Object {
"webapp/localService/mainService/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\\">
<edmx:Reference Uri=\\"https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Aggregation.V1.xml\\">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@ 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: []
annotations:
- localPath: ./webapp/annotations/annotation.xml
urlPath: annotations/annotation.xml
",
"state": "modified",
},
Expand Down Expand Up @@ -134,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 @@ -275,7 +277,7 @@ appDescription=A Fiori application.",
</html>",
"state": "modified",
},
"webapp/localService/metadata.xml": Object {
"webapp/localService/mainService/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\\"
xmlns=\\"http://docs.oasis-open.org/odata/ns/edm\\">
Expand Down Expand Up @@ -3813,10 +3815,12 @@ 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: []
annotations:
- localPath: ./webapp/annotations/annotation.xml
urlPath: annotations/annotation.xml
builder:
customTasks:
- name: ui5-tooling-transpile-task
Expand Down Expand Up @@ -3874,8 +3878,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 @@ -4038,7 +4042,7 @@ appDescription=A Fiori application.",
</html>",
"state": "modified",
},
"webapp/localService/metadata.xml": Object {
"webapp/localService/mainService/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\\"
xmlns=\\"http://docs.oasis-open.org/odata/ns/edm\\">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ 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: []
annotations:
- localPath: ./webapp/annotations/annotation.xml
urlPath: annotations/annotation.xml
",
"state": "modified",
},
Expand Down Expand Up @@ -135,8 +137,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 @@ -325,7 +327,7 @@ MainTitle=Main",
</html>",
"state": "modified",
},
"webapp/localService/metadata.xml": Object {
"webapp/localService/mainService/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\\"
xmlns=\\"http://docs.oasis-open.org/odata/ns/edm\\">
Expand Down Expand Up @@ -3832,10 +3834,12 @@ 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: []
annotations:
- localPath: ./webapp/annotations/annotation.xml
urlPath: annotations/annotation.xml
builder:
customTasks:
- name: ui5-tooling-transpile-task
Expand Down Expand Up @@ -3893,8 +3897,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 @@ -4158,7 +4162,7 @@ MainTitle=Main",
</html>",
"state": "modified",
},
"webapp/localService/metadata.xml": Object {
"webapp/localService/mainService/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\\"
xmlns=\\"http://docs.oasis-open.org/odata/ns/edm\\">
Expand Down
Loading
Loading