Skip to content

Commit

Permalink
Merge branch 'main' into refactor/2220/fix-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
voicis authored Sep 18, 2024
2 parents 95064af + b6a9bbb commit 6cb3210
Show file tree
Hide file tree
Showing 61 changed files with 1,301 additions and 446 deletions.
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,23 @@
},
"cwd": "${workspaceFolder}/packages/xml-odata-annotation-converter"
},
{
"type": "node",
"request": "launch",
"name": "adp-tooling: Debug Current Jest File",
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
"args": ["${fileBasenameNoExtension}", "--config", "jest.config.js", "--coverage=false", "--runInBand"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
},
"cwd": "${workspaceFolder}/packages/adp-tooling",
"env": {
"UX_DEBUG": "false"
}
},
{
"type": "node",
"request": "launch",
Expand Down
22 changes: 21 additions & 1 deletion docs/version-overrides.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

This document lists the version overrides for vulnerable (nested) dependencies and the reason.

```
## @ui5/cli -> @ui5/server -> router

- waiting on UI5 fixes to be released
- may be necessary to upgrade to version 4 of the UI5 cli

```
┌─────────────────────┬────────────────────────────────────────────────────────┐
│ high │ path-to-regexp outputs backtracking regular │
│ │ expressions │
├─────────────────────┼────────────────────────────────────────────────────────┤
│ Package │ path-to-regexp │
├─────────────────────┼────────────────────────────────────────────────────────┤
│ Vulnerable versions │ <0.1.10 │
├─────────────────────┼────────────────────────────────────────────────────────┤
│ Patched versions │ >=0.1.10 │
├─────────────────────┼────────────────────────────────────────────────────────┤
│ Paths │ packages\preview-middleware-client > @ui5/[email protected] > │
│ │ @ui5/[email protected] > [email protected] > │
│ │ [email protected]
├─────────────────────┼────────────────────────────────────────────────────────┤
│ More info │ https://github.com/advisories/GHSA-9wv6-86v2-598j │
└─────────────────────┴────────────────────────────────────────────────────────┘
```
7 changes: 7 additions & 0 deletions examples/fe-fpm-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @sap-ux/fe-fpm-cli

## 0.0.27

### Patch Changes

- Updated dependencies [327ebec]
- @sap-ux/fe-fpm-writer@0.31.0

## 0.0.26

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/fe-fpm-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sap-ux/fe-fpm-cli",
"version": "0.0.26",
"version": "0.0.27",
"description": "A simple CLI to prompt required information to create a building block using the fe-fpm-writer module's prompt and generate functions.",
"license": "Apache-2.0",
"private": true,
Expand Down
7 changes: 7 additions & 0 deletions examples/prompting-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @sap-ux/fe-fpm-writer-ui

## 0.1.0

### Minor Changes

- 327ebec: Divide chart, filter bar and table building block prompts questions into groups, add Manifest Change group.
Update custom chart example in prompting-ui.

## 0.0.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/prompting-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sap-ux/prompting-ui",
"version": "0.0.12",
"version": "0.1.0",
"description": "This project contains UI storybook stories with exampleS with prompt ui and FPM based building blocks.",
"license": "Apache-2.0",
"private": true,
Expand Down
14 changes: 7 additions & 7 deletions examples/prompting-ui/src/Custom.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ export const CustomChart = (): JSX.Element => {
<BuildingBlockQuestions
type={PromptsType.Chart}
visibleQuestions={[
'id',
'entity',
'qualifier',
'filterBar',
'selectionMode',
'selectionChange',
'bindingContextType'
'buildingBlockData.id',
'buildingBlockData.metaPath.entitySet',
'buildingBlockData.metaPath.qualifier',
'buildingBlockData.filterBar',
'buildingBlockData.selectionMode',
'buildingBlockData.selectionChange',
'buildingBlockData.metaPath.bindingContextType'
]}
/>
);
Expand Down
6 changes: 6 additions & 0 deletions examples/simple-generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sap-ux/generator-simple-fe

## 1.0.48

### Patch Changes

- @sap-ux/fiori-elements-writer@1.1.22

## 1.0.47

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-generator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sap-ux/generator-simple-fe",
"version": "1.0.47",
"version": "1.0.48",
"description": "Simple example of a yeoman generator for Fiori elements.",
"license": "Apache-2.0",
"private": true,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"packageManager": "[email protected]",
"pnpm": {
"overrides": {
"router>path-to-regexp": "0.1.10"
}
}
}
6 changes: 6 additions & 0 deletions packages/adp-tooling/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sap-ux/adp-tooling

## 0.12.48

### Patch Changes

- 2fd82b1: Object Page Add Custom Section quick action support

## 0.12.47

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/adp-tooling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"bugs": {
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aadp-tooling"
},
"version": "0.12.47",
"version": "0.12.48",
"license": "Apache-2.0",
"author": "@SAP/ux-tools-team",
"main": "dist/index.js",
Expand Down Expand Up @@ -65,7 +65,7 @@
"@types/supertest": "2.0.12",
"@types/uuid": "10.0.0",
"dotenv": "16.3.1",
"express": "4.19.2",
"express": "4.21.0",
"nock": "13.4.0",
"rimraf": "5.0.5",
"supertest": "6.3.3"
Expand Down
44 changes: 40 additions & 4 deletions packages/adp-tooling/src/preview/change-handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
import type { Editor } from 'mem-fs-editor';
import { TemplateFileName } from '../types';
import type { AddXMLChange, CommonChangeProperties, CodeExtChange } from '../types';
import { join } from 'path';
import { DirName } from '@sap-ux/project-access';
import type { Logger } from '@sap-ux/logger';
import { render } from 'ejs';
import { randomBytes } from 'crypto';

const OBJECT_PAGE_CUSTOM_SECTION = 'OBJECT_PAGE_CUSTOM_SECTION';

interface FragmentTemplateConfig<T = { [key: string]: any }> {
/**
* Relative path to ../../templates/rta, includes template file name
*/
path: string;
getData: () => T;
}

const fragmentTemplateDefinitions: Record<string, FragmentTemplateConfig> = {
[OBJECT_PAGE_CUSTOM_SECTION]: {
path: 'common/op-custom-section.xml',
getData: () => {
const uuid = randomBytes(4).toString('hex');
return {
ids: {
objectPageSection: `op-section-${uuid}`,
objectPageSubSection: `op-subsection-${uuid}`,
hBox: `hbox-${uuid}`
}
};
}
}
};

/**
* A mapping object that defines how to extract change content data from changes based on their type.
Expand Down Expand Up @@ -58,10 +85,19 @@ export function isAddXMLChange(change: CommonChangeProperties): change is AddXML
export function addXmlFragment(basePath: string, change: AddXMLChange, fs: Editor, logger: Logger): void {
const { fragmentPath } = change.content;
const fullPath = join(basePath, DirName.Changes, fragmentPath);

const templateConfig = fragmentTemplateDefinitions[change.content?.templateName ?? ''];
try {
const fragmentTemplatePath = join(__dirname, '../../templates/rta', TemplateFileName.Fragment);
fs.copy(fragmentTemplatePath, fullPath);
if (templateConfig) {
const fragmentTemplatePath = join(__dirname, '../../templates/rta', templateConfig.path);
const text = fs.read(fragmentTemplatePath);
const template = render(text, templateConfig.getData());
fs.write(fullPath, template);
} else {
// copy default fragment template
const templateName = 'fragment.xml'; /* TemplateFileName.Fragment */
const fragmentTemplatePath = join(__dirname, '../../templates/rta', templateName);
fs.copy(fragmentTemplatePath, fullPath);
}
logger.info(`XML Fragment "${fragmentPath}" was created`);
} catch (error) {
logger.error(`Failed to create XML Fragment "${fragmentPath}": ${error}`);
Expand Down
1 change: 1 addition & 0 deletions packages/adp-tooling/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export interface AddXMLChange extends CommonChangeProperties {
targetAggregation: string;
index: number;
fragmentPath: string;
templateName?: string;
};
selector: {
id: string;
Expand Down
17 changes: 17 additions & 0 deletions packages/adp-tooling/templates/rta/common/op-custom-section.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Use stable and unique IDs!-->
<core:FragmentDefinition
xmlns:uxap="sap.uxap"
xmlns:core='sap.ui.core'
xmlns='sap.m'
>
<uxap:ObjectPageSection
id="<%- ids.objectPageSection %>"
title="New custom section"
>
<uxap:ObjectPageSubSection id="<%- ids.objectPageSubSection %>">
<HBox id="<%- ids.hBox %>">
<!-- add your xml here -->
</HBox>
</uxap:ObjectPageSubSection>
</uxap:ObjectPageSection>
</core:FragmentDefinition>
52 changes: 51 additions & 1 deletion packages/adp-tooling/test/unit/preview/change-handler.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
jest.mock('crypto', () => ({
randomBytes: jest.fn()
}));

import type { Logger } from '@sap-ux/logger';
import type { Editor } from 'mem-fs-editor';
import * as crypto from 'crypto';

import {
addXmlFragment,
Expand Down Expand Up @@ -123,7 +128,9 @@ describe('change-handler', () => {
describe('addXmlFragment', () => {
const mockFs = {
exists: jest.fn(),
copy: jest.fn()
copy: jest.fn(),
read: jest.fn(),
write: jest.fn()
};

const mockLogger = {
Expand All @@ -142,6 +149,8 @@ describe('change-handler', () => {
beforeEach(() => {
mockFs.exists.mockClear();
mockFs.copy.mockClear();
mockFs.read.mockClear();
mockFs.write.mockClear();
mockLogger.info.mockClear();
mockLogger.error.mockClear();
});
Expand All @@ -167,5 +176,46 @@ describe('change-handler', () => {
expect.stringContaining(`Failed to create XML Fragment "${fragmentName}.fragment.xml"`)
);
});

describe('custom fragments', () => {
beforeEach(() => {
jest.spyOn(crypto, 'randomBytes').mockImplementation((size: number) => Buffer.from('0'.repeat(size)));
});
it('should create Object Page custom section fragment', () => {
mockFs.exists.mockReturnValue(false);
const updatedChange = {
...change,
content: {
...change.content,
templateName: `OBJECT_PAGE_CUSTOM_SECTION`
}
} as unknown as AddXMLChange;
mockFs.read.mockReturnValue(`
id="<%- ids.objectPageSection %>"
id="<%- ids.objectPageSubSection %>"
id="<%- ids.hBox %>"`);
addXmlFragment(path, updatedChange, mockFs as unknown as Editor, mockLogger as unknown as Logger);

expect(mockFs.read).toHaveBeenCalled();
expect(
(mockFs.read.mock.calls[0][0] as string)
.replace(/\\/g, '/')
.endsWith('templates/rta/common/op-custom-section.xml')
).toBe(true);

expect(mockFs.write).toHaveBeenCalled();
expect(mockFs.write.mock.calls[0][0].replace(/\\/g, '/')).toMatchInlineSnapshot(
`"project/path/changes/Share.fragment.xml"`
);
expect(mockFs.write.mock.calls[0][1]).toMatchInlineSnapshot(`
"
id=\\"op-section-30303030\\"
id=\\"op-subsection-30303030\\"
id=\\"hbox-30303030\\""
`);

expect(mockLogger.info).toHaveBeenCalledWith(`XML Fragment "${fragmentName}.fragment.xml" was created`);
});
});
});
});
2 changes: 1 addition & 1 deletion packages/backend-proxy-middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@types/prompts": "2.4.4",
"@types/proxy-from-env": "1.0.1",
"@types/supertest": "2.0.12",
"express": "4.19.2",
"express": "4.21.0",
"nock": "13.4.0",
"supertest": "6.3.3",
"yaml": "2.2.2"
Expand Down
3 changes: 2 additions & 1 deletion packages/cards-editor-middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"@types/ejs": "3.1.2",
"@types/express": "4.17.21",
"@types/supertest": "2.0.12",
"supertest": "6.3.3"
"supertest": "6.3.3",
"express": "4.21.0"
},
"peerDependencies": {
"express": "4"
Expand Down
18 changes: 18 additions & 0 deletions packages/control-property-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# @sap-ux/control-property-editor

## 0.5.5

### Patch Changes

- 30360e9: Update the CSS variable "--vscode-font-family" with a MacOS-specific font-family to match the VSCode UI when the control property editor is running on MacOS.

## 0.5.4

### Patch Changes

- 9506a73: Uniform funnel checkboxes

## 0.5.3

### Patch Changes

- 2fd82b1: Object Page Add Custom Section quick action support

## 0.5.2

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/control-property-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Control Property Editor",
"description": "Control Property Editor",
"license": "Apache-2.0",
"version": "0.5.2",
"version": "0.5.5",
"main": "dist/app.js",
"repository": {
"type": "git",
Expand Down Expand Up @@ -37,7 +37,7 @@
"@types/remote-redux-devtools": "0.5.4",
"@types/source-map-support": "0.5.0",
"@types/react": "16.14.55",
"body-parser": "1.20.1",
"body-parser": "1.20.3",
"eslint-plugin-react": "7.33.2",
"http-proxy-middleware": "1.3.1",
"i18next": "20.6.1",
Expand Down
Loading

0 comments on commit 6cb3210

Please sign in to comment.