0.3.11 • Published 8 months ago

@sap-ux/ui5-library-inquirer v0.3.11

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

@sap-ux/ui5-library-inquirer

Provides Inquirer based prompting to allow input and validation of data required to generate a UI5 library

Installation

Npm npm install --save @sap-ux/ui5-library-inquirer

Yarn yarn add @sap-ux/ui5-library-inquirer

Pnpm pnpm add @sap-ux/ui5-library-inquirer

Usage

Example with Yeoman generator no options, e.g. cli prompting only :

import Generator from 'yeoman-generator';
import { generate, type UI5LibConfig } from '@sap-ux/ui5-library-writer';
import { prompt, type UI5LibraryAnswers } from '@sap-ux/ui5-library-inquirer';

export default class UI5LibraryGenerator extends Generator {
    answers: UI5LibraryAnswers = {};
 
    constructor(args: string | string[], opts: Generator.GeneratorOptions) {
        super(args, opts);
    }

    public async prompting(): Promise<void> {
        const answers = await prompt();
        Object.assign(this.answers, answers);
    }

     public async writing(): Promise<void> {
        const ui5Lib: UI5LibConfig = {
            libraryName: this.answers.libraryName,
            namespace: this.answers.namespace,
            framework: 'SAPUI5',
            frameworkVersion: this.answers.ui5Version,
            author: 'Fiori tools',
            typescript: this.answers.enableTypescript
        };

        try {
            await generate(this.answers.targetFolder, ui5Lib, this.fs);
        } catch (e) {}
    }
}

Example with Yeoman generator passing options with adapter, e.g. @sap-devx/yeoman-ui integration :

import Generator from 'yeoman-generator';
import { generate, type UI5LibConfig } from '@sap-ux/ui5-library-writer';
import { prompt, type UI5LibraryAnswers } from '@sap-ux/ui5-library-inquirer';

export default class UI5LibraryGenerator extends Generator {
    answers: UI5LibraryAnswers = {};
    targetFolder: string;
 
    constructor(args: string | string[], opts: Generator.GeneratorOptions) {
        super(args, opts);
        this.targetFolder = opts.targetFolder;
    }

    public async prompting(): Promise<void> {
        const answers = await prompt(
            {
                targetFolder: this.targetFolder,
                includeSeparators: true,
                useAutocomplete: false
            },
            this.env?.adapter
        );
        Object.assign(this.answers, answers);
    }

     public async writing(): Promise<void> {
        const ui5Lib: UI5LibConfig = {
            libraryName: this.answers.libraryName,
            namespace: this.answers.namespace,
            framework: 'SAPUI5',
            frameworkVersion: this.answers.ui5Version,
            author: 'Fiori tools',
            typescript: this.answers.enableTypescript
        };

        try {
            await generate(this.answers.targetFolder, ui5Lib, this.fs);
        } catch (e) {}
    }
}

Keywords

SAP Fiori Elements Yeoman Generator

0.3.11

8 months ago

0.3.10

8 months ago

0.3.9

8 months ago

0.3.8

8 months ago

0.2.16

12 months ago

0.2.15

1 year ago

0.3.0

12 months ago

0.3.6

10 months ago

0.3.5

11 months ago

0.3.7

10 months ago

0.3.2

11 months ago

0.3.1

11 months ago

0.3.4

11 months ago

0.3.3

11 months ago

0.2.14

1 year ago

0.2.13

1 year ago

0.2.12

1 year ago

0.2.11

1 year ago

0.2.10

1 year ago

0.2.9

1 year ago

0.2.8

1 year ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago