Skip to content

Commit

Permalink
Updates to fix broken imports
Browse files Browse the repository at this point in the history
  • Loading branch information
IainSAP committed Jul 18, 2024
1 parent 02a20f8 commit 60f42d9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 34 deletions.
9 changes: 4 additions & 5 deletions sample-fiori-gen-ext/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ This module is an example of how to extend `@sap/generator-fiori`, adding additi
## Building and installing the sample Fiori generator extension

1. Clone this repo locally.
2. Run `npm install` in the `sample-fiori-gen-ext` directory ( pre-requisite: `npm` is installed globally )
2. Run `yarn install` in the `sample-fiori-gen-ext` directory ( pre-requisite: `yarn` is installed globally )

### For local testing
1. Build the extension sample using `npm run build`
1. Build the extension sample using `yarn bundle`
2. Create the installable artefact by running `npm pack`
3. Install the tgz globally using `npm i -g <path-to-generated-tgz>`

### For bundling to deploy to Business Application Studio
To ensure dev space startup time is not negatively impacted by running installs it is recommended that the extension is bundled first. An example of bundling using `esbuild` is included (note: `shelljs` is included as a dependency as a workaround for a known `esbuild` issue):
1. Bundle the extension sample using `npm run bundle`
1. Bundle the extension sample using `yarn bundle`
2. The bundle should be checked in to the repo for deployment using the WEX tool (ADD LINK!!!)
3. To test locally create the installable artefact by running `npm pack`
4. To test locally install the tgz globally using `npm i -g <path-to-generated-tgz>`
Expand Down Expand Up @@ -89,8 +89,7 @@ Currently a limited set of prompts can be customized by providing properties for
- targetFolder : the absolute path where the application will be generated
- ui5Version : the minimum ui5 version defined in the application manifest.json

The complete set of extendable prompts is defined by the definition `FioriGeneratorPromptNames` exported by the node module `https://www.npmjs.com/package/@sap/generator-fiori`.

The complete set of extendable prompts is defined by the definition `promptNamea` exported by the node module `https://www.npmjs.com/package/@sap-ux/ui5-application-inquirer`. However `@sap-ux/ui5-application-inquirer` provides extensive customising using the export type `OdataServicePromptOptions`.
An example of providing `_getExtensions` might be:

```
Expand Down
7 changes: 4 additions & 3 deletions sample-fiori-gen-ext/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sample/fiori-gen-ext",
"version": "0.1.1",
"version": "0.2.0",
"description": "Sample Fiori generator extension sub-generator",
"keywords": [
"fiori-generator-extension"
Expand All @@ -26,15 +26,16 @@
},
"devDependencies": {
"@sap-devx/yeoman-ui-types": "1.14.0",
"@sap/generator-fiori": "^1.12.1",
"@sap/generator-fiori": "^1.14.1",
"@sap-ux/ui5-application-inquirer": "0.5.6",
"@types/yeoman-generator": "5.2.14",
"esbuild": "0.17.19",
"rimraf": "5.0.0",
"typescript": "4.9.4",
"yeoman-generator": "5.10.0"
},
"peerDependencies": {
"@sap/generator-fiori": "^1.12.1"
"@sap/generator-fiori": "^1.14.1"
},
"engines": {
"node": ">=16 <17 || >=18 <19 || >=20"
Expand Down
54 changes: 28 additions & 26 deletions sample-fiori-gen-ext/src/custom/questions.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
import { FioriGeneratorPromptExtension, FioriGeneratorPromptNames } from "@sap/generator-fiori";
// Get the Fiori generator "Project Attributes" step main question names
const { projectAttributes: { mainQuestions: questionNames } } = FioriGeneratorPromptNames;
import { FioriGeneratorPromptExtension } from "@sap/generator-fiori";
import { promptNames } from "@sap-ux/ui5-application-inquirer/dist/types";

export default {
"@sap/generator-fiori": {
[questionNames.name]: {
validate: (input: string): boolean | string => {
if (input.length < 3) {
return "Name length > 3";
}
return true;
},
default: "superapp1",
},
[questionNames.namespace]: {
validate: (input: string, previousAnswers?): boolean | string => {
if (input.indexOf("random") > -1) {
return `Input value: ${input} is not allowed`;
}
if (previousAnswers.name === input) {
return "Namespace should not match name";
}
return true;
},
default: (previousAnswers) => (previousAnswers.title === "App Title" ? "super.com" : "great.com"),
},
} as FioriGeneratorPromptExtension,
"@sap/generator-fiori": {
[promptNames.name]: {
validate: (input: string): boolean | string => {
if (input.length < 3) {
return "Name length > 3";
}
return true;
},
default: "superapp1",
},
[promptNames.namespace]: {
validate: (input: string, previousAnswers?): boolean | string => {
if (input.indexOf("random") > -1) {
return `Input value: ${input} is not allowed`;
}
if (previousAnswers.name === input) {
return "Namespace should not match name";
}
return true;
},
default: (previousAnswers) =>
previousAnswers.title === "App Title"
? "super.com"
: "great.com",
},
} as FioriGeneratorPromptExtension,
};

0 comments on commit 60f42d9

Please sign in to comment.