Skip to content

Commit

Permalink
Merge branch 'main' into fix/refactor-object-clones
Browse files Browse the repository at this point in the history
  • Loading branch information
heimwege authored Jan 9, 2025
2 parents c3c5397 + c022ace commit 564f56f
Show file tree
Hide file tree
Showing 283 changed files with 11,672 additions and 503 deletions.
11 changes: 11 additions & 0 deletions examples/odata-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @sap-ux/odata-cli

## 0.16.0

### Minor Changes

- 2e3c15e: Proper check for cloud ABAP systems

### Patch Changes

- Updated dependencies [2e3c15e]
- @sap-ux/axios-extension@1.18.0

## 0.15.16

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/odata-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sap-ux/odata-cli",
"version": "0.15.16",
"version": "0.16.0",
"description": "Simple example CLI uing the @sap-ux/axios-extension module to fetch metadata and annotations from an SAP system.",
"license": "Apache-2.0",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/odata-cli/src/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export async function testUiServiceGenerator(
TEST_TRANSPORT: string;
}
): Promise<void> {
const s4Cloud = await provider.isS4Cloud();
const s4Cloud = await provider.isAbapCloud();
if (!s4Cloud) {
logger.warn('Not an S/4 Cloud system. UI service generation might not be supported.');
}
Expand Down
15 changes: 15 additions & 0 deletions examples/simple-generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# @sap-ux/generator-simple-fe

## 1.0.103

### Patch Changes

- Updated dependencies [2e3c15e]
- @sap-ux/axios-extension@1.18.0
- @sap-ux/system-access@0.5.25

## 1.0.102

### Patch Changes

- @sap-ux/fiori-elements-writer@1.3.42
- @sap-ux/fiori-freestyle-writer@1.2.38

## 1.0.101

### 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.101",
"version": "1.0.103",
"description": "Simple example of a yeoman generator for Fiori elements.",
"license": "Apache-2.0",
"private": true,
Expand Down
23 changes: 23 additions & 0 deletions packages/abap-deploy-config-inquirer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# @sap-ux/abap-deploy-config-inquirer

## 1.1.19

### Patch Changes

- Updated dependencies [40ba546]
- @sap-ux/inquirer-common@0.6.3

## 1.1.18

### Patch Changes

- Updated dependencies [dac696a]
- @sap-ux/guided-answers-helper@0.2.0
- @sap-ux/inquirer-common@0.6.2

## 1.1.17

### Patch Changes

- Updated dependencies [2e3c15e]
- @sap-ux/axios-extension@1.18.0
- @sap-ux/system-access@0.5.25

## 1.1.16

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/abap-deploy-config-inquirer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "https://github.com/SAP/open-ux-tools.git",
"directory": "packages/abap-deploy-config-inquirer"
},
"version": "1.1.16",
"version": "1.1.19",
"license": "Apache-2.0",
"main": "dist/index.js",
"scripts": {
Expand Down
20 changes: 20 additions & 0 deletions packages/abap-deploy-config-sub-generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# @sap-ux/abap-deploy-config-sub-generator

## 0.0.11

### Patch Changes

- @sap-ux/abap-deploy-config-inquirer@1.1.19

## 0.0.10

### Patch Changes

- @sap-ux/abap-deploy-config-inquirer@1.1.18

## 0.0.9

### Patch Changes

- @sap-ux/abap-deploy-config-inquirer@1.1.17
- @sap-ux/deploy-config-generator-shared@0.0.9
- @sap-ux/abap-deploy-config-writer@0.0.72

## 0.0.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/abap-deploy-config-sub-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "https://github.com/SAP/open-ux-tools.git",
"directory": "packages/abap-deploy-config-sub-generator"
},
"version": "0.0.8",
"version": "0.0.11",
"license": "Apache-2.0",
"main": "generators/app/index.js",
"scripts": {
Expand Down
6 changes: 6 additions & 0 deletions packages/abap-deploy-config-writer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sap-ux/abap-deploy-config-writer

## 0.0.72

### Patch Changes

- @sap-ux/system-access@0.5.25

## 0.0.71

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/abap-deploy-config-writer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "https://github.com/SAP/open-ux-tools.git",
"directory": "packages/abap-deploy-config-writer"
},
"version": "0.0.71",
"version": "0.0.72",
"license": "Apache-2.0",
"main": "dist/index.js",
"scripts": {
Expand Down
28 changes: 28 additions & 0 deletions packages/adp-tooling/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# @sap-ux/adp-tooling

## 0.12.105

### Patch Changes

- 19d51f3: feat: Quick Action For Add New Annotation File

## 0.12.104

### Patch Changes

- Updated dependencies [40ba546]
- @sap-ux/inquirer-common@0.6.3

## 0.12.103

### Patch Changes

- Updated dependencies [dac696a]
- @sap-ux/inquirer-common@0.6.2

## 0.12.102

### Patch Changes

- Updated dependencies [2e3c15e]
- @sap-ux/axios-extension@1.18.0
- @sap-ux/system-access@0.5.25

## 0.12.101

### Patch Changes
Expand Down
3 changes: 2 additions & 1 deletion 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.101",
"version": "0.12.105",
"license": "Apache-2.0",
"author": "@SAP/ux-tools-team",
"main": "dist/index.js",
Expand Down Expand Up @@ -43,6 +43,7 @@
"@sap-ux/project-input-validator": "workspace:*",
"@sap-ux/system-access": "workspace:*",
"@sap-ux/ui5-config": "workspace:*",
"@sap-ux/odata-service-writer": "workspace:*",
"@sap-ux/i18n": "workspace:*",
"adm-zip": "0.5.10",
"ejs": "3.1.10",
Expand Down
2 changes: 1 addition & 1 deletion packages/adp-tooling/src/base/abap/manifest-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { isAxiosError, type AbapServiceProvider, type Ui5AppInfoContent } from '
import { getWebappFiles } from '../helper';
import type { DescriptorVariant } from '../../types';

type DataSources = Record<string, ManifestNamespace.DataSource>;
export type DataSources = Record<string, ManifestNamespace.DataSource>;

/**
* Retrieves the inbound navigation configurations from the project's manifest.
Expand Down
12 changes: 7 additions & 5 deletions packages/adp-tooling/src/base/change-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@ export function writeAnnotationChange(
projectPath: string,
timestamp: number,
annotation: AnnotationsData['annotation'],
change: ManifestChangeProperties,
change: ManifestChangeProperties | undefined,
fs: Editor
): void {
try {
const changeFileName = `id_${timestamp}_addAnnotationsToOData.change`;
const changesFolderPath = path.join(projectPath, DirName.Webapp, DirName.Changes);
const changeFilePath = path.join(changesFolderPath, changeFileName);
const annotationsFolderPath = path.join(changesFolderPath, DirName.Annotations);

writeChangeToFile(changeFilePath, change, fs);
if (change) {
const changeFileName = `id_${timestamp}_addAnnotationsToOData.change`;
const changeFilePath = path.join(changesFolderPath, changeFileName);
change.fileName = `${change.fileName}_addAnnotationsToOData`;
writeChangeToFile(changeFilePath, change, fs);
}

if (!annotation.filePath) {
const annotationsTemplate = path.join(
Expand Down
26 changes: 24 additions & 2 deletions packages/adp-tooling/src/preview/adp-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ import type { LayeredRepositoryService, MergedAppDescriptor } from '@sap-ux/axio
import RoutesHandler from './routes-handler';
import type { AdpPreviewConfig, CommonChangeProperties, DescriptorVariant, OperationType } from '../types';
import type { Editor } from 'mem-fs-editor';
import { addXmlFragment, isAddXMLChange, moduleNameContentMap, tryFixChange } from './change-handler';
import {
addAnnotationFile,
addXmlFragment,
isAddAnnotationChange,
isAddXMLChange,
moduleNameContentMap,
tryFixChange
} from './change-handler';
declare global {
// false positive, const can't be used here https://github.com/eslint/eslint/issues/15896
// eslint-disable-next-line no-var
Expand All @@ -21,7 +28,8 @@ declare global {
export const enum ApiRoutes {
FRAGMENT = '/adp/api/fragment',
CONTROLLER = '/adp/api/controller',
CODE_EXT = '/adp/api/code_ext/:controllerName'
CODE_EXT = '/adp/api/code_ext/:controllerName',
ANNOTATION = '/adp/api/annotation'
}

/**
Expand Down Expand Up @@ -198,6 +206,11 @@ export class AdpPreview {
router.post(ApiRoutes.CONTROLLER, this.routesHandler.handleWriteControllerExt as RequestHandler);

router.get(ApiRoutes.CODE_EXT, this.routesHandler.handleGetControllerExtensionData as RequestHandler);
router.post(ApiRoutes.ANNOTATION, this.routesHandler.handleCreateAnnotationFile as RequestHandler);
router.get(
ApiRoutes.ANNOTATION,
this.routesHandler.handleGetAllAnnotationFilesMappedByDataSource as RequestHandler
);
}

/**
Expand Down Expand Up @@ -225,6 +238,15 @@ export class AdpPreview {
if (isAddXMLChange(change)) {
addXmlFragment(this.util.getProject().getSourcePath(), change, fs, logger);
}
if (isAddAnnotationChange(change)) {
await addAnnotationFile(
this.util.getProject().getSourcePath(),
this.util.getProject().getRootPath(),
change,
fs,
logger
);
}
break;
default:
// no need to handle delete changes
Expand Down
85 changes: 81 additions & 4 deletions packages/adp-tooling/src/preview/change-handler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import type { Editor } from 'mem-fs-editor';
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 type { AddXMLChange, CommonChangeProperties, CodeExtChange, AnnotationFileChange } from '../types';
import { ChangeType } from '../types';
import { basename, join } from 'path';
import { DirName, FileName } from '@sap-ux/project-access';
import type { Logger, ToolsLogger } from '@sap-ux/logger';
import { render } from 'ejs';
import { randomBytes } from 'crypto';
import { ManifestService } from '../base/abap/manifest-service';
import { getAdpConfig, getVariant } from '../base/helper';
import { createAbapServiceProvider } from '@sap-ux/system-access';
import { getAnnotationNamespaces } from '@sap-ux/odata-service-writer';
import { generateChange } from '../writer/editors';

const OBJECT_PAGE_CUSTOM_SECTION = 'OBJECT_PAGE_CUSTOM_SECTION';
const CUSTOM_ACTION = 'CUSTOM_ACTION';
Expand Down Expand Up @@ -167,6 +173,17 @@ export function isAddXMLChange(change: CommonChangeProperties): change is AddXML
return change.changeType === 'addXML' || change.changeType === 'addXMLAtExtensionPoint';
}

/**
* Determines whether a given change is of type `AnnotationFileChange`.
*
* @param {CommonChangeProperties} change - The change object to check.
* @returns {boolean} `true` if the `changeType` is either 'appdescr_app_addAnnotationsToOData',
* indicating the change is of type `AnnotationFileChange`.
*/
export function isAddAnnotationChange(change: CommonChangeProperties): change is AnnotationFileChange {
return change.changeType === 'appdescr_app_addAnnotationsToOData';
}

/**
* Asynchronously adds an XML fragment to the project if it doesn't already exist.
*
Expand Down Expand Up @@ -196,3 +213,63 @@ export function addXmlFragment(basePath: string, change: AddXMLChange, fs: Edito
logger.error(`Failed to create XML Fragment "${fragmentPath}": ${error}`);
}
}

/**
* Asynchronously adds an XML fragment to the project if it doesn't already exist.
*
* @param {string} basePath - The base path of the project.
* @param {string} projectRoot - The root path of the project.
* @param {AddXMLChange} change - The change data, including the fragment path.
* @param {Editor} fs - The mem-fs-editor instance.
* @param {Logger} logger - The logging instance.
*/
export async function addAnnotationFile(
basePath: string,
projectRoot: string,
change: AnnotationFileChange,
fs: Editor,
logger: Logger
): Promise<void> {
const { dataSourceId, annotations, dataSource } = change.content;
const annotationDataSourceKey = annotations[0];
const annotationUriSegments = dataSource[annotationDataSourceKey].uri.split('/');
annotationUriSegments.shift();
const fullPath = join(basePath, DirName.Changes, ...annotationUriSegments);
try {
const manifestService = await getManifestService(projectRoot, logger);
const metadata = await manifestService.getDataSourceMetadata(dataSourceId);
const datasoruces = await manifestService.getManifestDataSources();
const namespaces = getAnnotationNamespaces({ metadata });
await generateChange<ChangeType.ADD_ANNOTATIONS_TO_ODATA>(
projectRoot,
ChangeType.ADD_ANNOTATIONS_TO_ODATA,
{
annotation: {
dataSource: dataSourceId,
namespaces,
serviceUrl: datasoruces[dataSourceId].uri,
fileName: basename(dataSource[annotationDataSourceKey].uri)
},
variant: getVariant(projectRoot),
isCommand: false
},
fs
);
} catch (error) {
logger.error(`Failed to create Local Annotation File "${fullPath}": ${error}`);
}
}

/**
* Returns manifest service.
*
* @param {string} basePath - The base path of the project.
* @param {Logger} logger - The logging instance.
* @returns Promise<ManifestService>
*/
async function getManifestService(basePath: string, logger: Logger): Promise<ManifestService> {
const variant = getVariant(basePath);
const { target, ignoreCertErrors = false } = await getAdpConfig(basePath, join(basePath, FileName.Ui5Yaml));
const provider = await createAbapServiceProvider(target, { ignoreCertErrors }, true, logger);
return await ManifestService.initMergedManifest(provider, basePath, variant, logger as unknown as ToolsLogger);
}
Loading

0 comments on commit 564f56f

Please sign in to comment.