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

FEATURE - Add an option to open source FEwriter generate to enable writing annotations. #2773

Open
2 tasks
kjose90 opened this issue Jan 14, 2025 · 0 comments
Open
2 tasks
Assignees

Comments

@kjose90
Copy link
Member

kjose90 commented Jan 14, 2025

Extend the open-source Fiori Elements/ Fiori Freesryle writer's generate method to support annotation writing as part of the app generation process. This can be done by -

  1. Adding an optional property writeAnnotations to the appOptions of the FioriElementsApp interface here.

packages/fiori-elements-writer/src/types.ts

import { type GenerateAnnotationsOptions } from '@sap-ux/annotation-generator';

interface WriteAnnotationsConfig extends GenerateAnnotationsOptions {
    /* The name of the service, CAP service name or 'mainService' by default. */
    serviceName: string;
}

export interface FioriElementsApp<T> extends Ui5App {
    template: Template<T>;
    service: Omit<OdataService, 'model'>; // Model name will use defaults
    app: FioriApp;
    appOptions: Partial<AppOptions> & {
        ....
        addTests?: boolean;
        writeAnnotations?: WriteAnnotationsConfig;
    };
}
  1. Update the generate Method of the Fiori Elements Writer. Check if writeAnnotations is provided in appOptions. If it's present, the annotation writing logic will be invoked during the app generation.
    packages/fiori-elements-writer/src/index.ts
import {
    generateAnnotations,
    type AnnotationServiceParameters
} from '@sap-ux/annotation-generator';

export async function generate<T>(
    destinationPath: string,
    app: FioriElementsApp<T>,
    fs: Editor
): Promise<void> {
    // Existing logic for file generation
    ...

       // Handle annotation writing if configuration is provided
    if (app.appOptions.writeAnnotations) {
        const { serviceName, ...annotationOptions } = feApp.appOptions.writeAnnotations;
        const annoServiceParams: AnnotationServiceParameters = { 
            serviceName, 
            appName: feApp.package.name, 
            project: // get project path from annotationFilePath 
        };

        await generateAnnotations(fs, annoServiceParams, annotationOptions);
    }

    ...
}

Architecture Elaboration

Does it requires architecture elaboration?

Notes

Tasks

  • Adding an optional property writeAnnotations to the appOptions of the FioriElementsApp interface
  • Update the generate Method of the Fiori Elements Writer
@kjose90 kjose90 self-assigned this Jan 14, 2025
@kjose90 kjose90 changed the title FEATURE - Add an option to open source FE writer generate to enable writing annotations. FEATURE - Add an option to open source FE/FF writer generate to enable writing annotations. Jan 14, 2025
@kjose90 kjose90 changed the title FEATURE - Add an option to open source FE/FF writer generate to enable writing annotations. FEATURE - Add an option to open source FEwriter generate to enable writing annotations. Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant