Skip to content

Commit

Permalink
Merge branch 'main' into chore/update-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
voicis authored Jan 17, 2025
2 parents 7a3e459 + e12ed73 commit 21d4b13
Show file tree
Hide file tree
Showing 74 changed files with 18,176 additions and 411 deletions.
38 changes: 38 additions & 0 deletions examples/simple-generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
# @sap-ux/generator-simple-fe

## 1.0.109

### Patch Changes

- 77b0800: Adds support for entity related prompting. Update some exported types `fiori-elements-writer`, `fiori-freestyle-writer` to remove problematic enum usage.
The major version updates for modules `@sap-ux/fiori-elements-writer` and `@sap-ux/fiori-freestyle-writer` indicates a breaking change of type definitions:

`@sap-ux/fiori-elements-writer`:
`TemplateType`
`TableType`
`TableSelectionMode`

`@sap-ux/fiori-freestyle-writer`:
`TemplateType`

These changes are required to reduce the impact of importing these types by consumers. Previously defined as enums, requiring full dependencies and bloating
consumer code where only these types are required. The new type defintions still allow both uses (type or value) but the `enums` are now defined as `const`.
This change requires updates to consuming code where the type is imported and referenced.
Example where a single enum was used as a value type:

```
type Template = {
template: TemplateType.ListReportObjectPage
}
```
should now be defined as:
```
type Template = {
template: typeof TemplateType.ListReportObjectPage
}
```
- Updated dependencies [77b0800]
- @sap-ux/[email protected]
- @sap-ux/[email protected]
## 1.0.108
### 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.108",
"version": "1.0.109",
"description": "Simple example of a yeoman generator for Fiori elements.",
"license": "Apache-2.0",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-generator/src/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class extends Generator {
private app!: Ui5App & { app: { flpAppId: string } };
private service!: OdataService;
private template: {
type: TemplateType | FreestyleTemplateType.Basic;
type: TemplateType | typeof FreestyleTemplateType.Basic;
settings?: LROPSettings | OVPSettings | {};
};

Expand Down
6 changes: 6 additions & 0 deletions packages/abap-deploy-config-inquirer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sap-ux/abap-deploy-config-inquirer

## 1.2.0

### Minor Changes

- fc5916a: exposes getpackageprompts and gettransportrequest prompts

## 1.1.21

### 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.21",
"version": "1.2.0",
"license": "Apache-2.0",
"main": "dist/index.js",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion packages/abap-deploy-config-inquirer/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ToolsLogger, type Logger } from '@sap-ux/logger';
import { initI18n } from './i18n';
import { PromptState } from './prompts/prompt-state';
import { getAbapDeployConfigQuestions } from './prompts';
import { getAbapDeployConfigQuestions, getPackagePrompts, getTransportRequestPrompts } from './prompts';
import { getPackageAnswer, getTransportAnswer, reconcileAnswers } from './utils';
import LoggerHelper from './logger-helper';
import type { InquirerAdapter } from '@sap-ux/inquirer-common';
Expand Down Expand Up @@ -70,6 +70,8 @@ export {
getPackageAnswer,
getTransportAnswer,
reconcileAnswers,
getPackagePrompts,
getTransportRequestPrompts,
TargetSystemType,
PackageInputChoices,
TransportChoices,
Expand Down
16 changes: 6 additions & 10 deletions packages/abap-deploy-config-inquirer/src/prompts/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
TransportChoices,
type AbapSystemChoice,
type AbapDeployConfigAnswersInternal,
type BackendTarget
type BackendTarget,
type SystemConfig
} from '../types';
import { AuthenticationType, type BackendSystem } from '@sap-ux/store';
import type { ChoiceOptions, ListChoiceOptions } from 'inquirer';
Expand Down Expand Up @@ -248,29 +249,24 @@ export function updatePromptStateUrl(
*
* @param isCli - is running in CLI
* @param input - package input
* @param systemConfig - system configuration
* @param previousAnswers - previous answers
* @param backendTarget - backend target from abap deploy config prompt options
* @returns results of query and message based on number of results
*/
export async function getPackageChoices(
isCli: boolean,
input: string,
systemConfig: SystemConfig,
previousAnswers: AbapDeployConfigAnswersInternal,
backendTarget?: BackendTarget
): Promise<{ packages: string[]; morePackageResultsMsg: string }> {
let packages;
let morePackageResultsMsg = '';

// For YUI we need to ensure input is provided so the prompt is not re-rendered with no input
if (isCli || input) {
packages = await queryPackages(
input,
{
url: PromptState.abapDeployConfig.url,
client: PromptState.abapDeployConfig.client,
destination: PromptState.abapDeployConfig.destination
},
backendTarget
);
packages = await queryPackages(input, systemConfig, backendTarget);

morePackageResultsMsg =
packages && packages.length === ABAP_PACKAGE_SEARCH_MAX_RESULTS
Expand Down
9 changes: 6 additions & 3 deletions packages/abap-deploy-config-inquirer/src/prompts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getTransportRequestPrompts,
getConfirmPrompts
} from './questions';
import { PromptState } from './prompt-state';
import type { AbapDeployConfigQuestion, AbapDeployConfigPromptOptions } from '../types';

/**
Expand All @@ -14,7 +15,7 @@ import type { AbapDeployConfigQuestion, AbapDeployConfigPromptOptions } from '..
* @param options - abap deploy config prompt options
* @returns the abap deployment config questions
*/
export async function getAbapDeployConfigQuestions(
async function getAbapDeployConfigQuestions(
options?: AbapDeployConfigPromptOptions
): Promise<AbapDeployConfigQuestion[]> {
options = options ?? {};
Expand All @@ -27,11 +28,13 @@ export async function getAbapDeployConfigQuestions(
questions.push(...getAppConfigPrompts(options));
}

const packagePrompts = getPackagePrompts(options);
const transportRequestPrompts = getTransportRequestPrompts(options);
const packagePrompts = getPackagePrompts(options, false, PromptState.isYUI);
const transportRequestPrompts = getTransportRequestPrompts(options, false, PromptState.isYUI);
const confirmPrompts = getConfirmPrompts(options);

questions.push(...packagePrompts, ...transportRequestPrompts, ...confirmPrompts);

return questions as AbapDeployConfigQuestion[];
}

export { getAbapDeployConfigQuestions, getPackagePrompts, getTransportRequestPrompts };
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
showPackageInputChoiceQuestion
} from '../../conditions';
import { t } from '../../../i18n';
import { getSystemConfig } from '../../../utils';
import { getPackageChoices, getPackageInputChoices } from '../../helpers';
import { defaultPackage, defaultPackageChoice } from '../../defaults';
import { validatePackage, validatePackageChoiceInput, validatePackageChoiceInputForCli } from '../../validators';
Expand All @@ -21,12 +22,18 @@ import type { AutocompleteQuestionOptions } from 'inquirer-autocomplete-prompt';
* Returns the package prompts.
*
* @param options - abap deploy config prompt options
* @param useStandalone - whether the prompts are used standalone, defaults to true
* @param isYUI - if true, the prompt is being called from the Yeoman UI extension host
* @returns list of list of questions for package prompting
*/
export function getPackagePrompts(options: AbapDeployConfigPromptOptions): Question<AbapDeployConfigAnswersInternal>[] {
export function getPackagePrompts(
options: AbapDeployConfigPromptOptions,
useStandalone = true,
isYUI = false
): Question<AbapDeployConfigAnswersInternal>[] {
let packageInputChoiceValid: boolean | string;
let morePackageResultsMsg = '';
const isCli = !PromptState.isYUI;
PromptState.isYUI = isYUI;

const questions: Question<AbapDeployConfigAnswersInternal>[] = [
{
Expand All @@ -43,28 +50,21 @@ export function getPackagePrompts(options: AbapDeployConfigPromptOptions): Quest
validate: async (input: PackageInputChoices): Promise<boolean | string> => {
packageInputChoiceValid = await validatePackageChoiceInput(
input,
{
url: PromptState.abapDeployConfig.url,
client: PromptState.abapDeployConfig.client,
destination: PromptState.abapDeployConfig.destination
},
getSystemConfig(useStandalone, PromptState.abapDeployConfig, options.backendTarget),
options.backendTarget
);
return packageInputChoiceValid;
}
} as ListQuestion<AbapDeployConfigAnswersInternal>,
{
when: async (previousAnswers: AbapDeployConfigAnswersInternal): Promise<boolean> => {
if (isCli) {
if (!PromptState.isYUI) {
await validatePackageChoiceInputForCli(
{
url: PromptState.abapDeployConfig.url,
client: PromptState.abapDeployConfig.client,
destination: PromptState.abapDeployConfig.destination
},
getSystemConfig(useStandalone, PromptState.abapDeployConfig, options.backendTarget),
previousAnswers.packageInputChoice,
options.backendTarget
);

packageInputChoiceValid = true;
}
return false;
Expand Down Expand Up @@ -101,7 +101,7 @@ export function getPackagePrompts(options: AbapDeployConfigPromptOptions): Quest
type: 'autocomplete',
name: promptNames.packageAutocomplete,
message: `${t('prompts.config.package.packageAutocomplete.message')}${
isCli ? t('prompts.config.package.packageAutocomplete.messageTypeFilter') : ''
!PromptState.isYUI ? t('prompts.config.package.packageAutocomplete.messageTypeFilter') : ''
}`,
guiOptions: {
hint: t('prompts.config.package.packageAutocomplete.hint'),
Expand All @@ -112,7 +112,13 @@ export function getPackagePrompts(options: AbapDeployConfigPromptOptions): Quest
previousAnswers: AbapDeployConfigAnswersInternal,
input: string
): Promise<string[] | undefined> => {
const results = await getPackageChoices(isCli, input, previousAnswers, options.backendTarget);
const results = await getPackageChoices(
!PromptState.isYUI,
input,
getSystemConfig(useStandalone, PromptState.abapDeployConfig, options.backendTarget),
previousAnswers,
options.backendTarget
);
morePackageResultsMsg = results.morePackageResultsMsg;
return results.packages;
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { t } from '../../../i18n';

import {
defaultOrShowManualTransportQuestion,
defaultOrShowTransportCreatedQuestion,
Expand All @@ -24,12 +23,17 @@ import { useCreateTrDuringDeploy } from '../../../utils';
* Returns the transport prompts.
*
* @param options - abap deploy config prompt options
* @param useStandalone - whether the prompts are used standalone, defaults to true
* @param isYUI - if true, the prompt is being called from the Yeoman UI extension host
* @returns list of questions for transport prompting
*/
export function getTransportRequestPrompts(
options: AbapDeployConfigPromptOptions
options: AbapDeployConfigPromptOptions,
useStandalone = true,
isYUI = false
): Question<AbapDeployConfigAnswersInternal>[] {
let transportInputChoice: TransportChoices;
PromptState.isYUI = isYUI;

const questions: Question<AbapDeployConfigAnswersInternal>[] = [
{
Expand All @@ -50,7 +54,15 @@ export function getTransportRequestPrompts(
input: TransportChoices,
previousAnswers: AbapDeployConfigAnswersInternal
): Promise<boolean | string> => {
const result = validateTransportChoiceInput(input, previousAnswers, true, transportInputChoice);
const result = validateTransportChoiceInput(
useStandalone,
input,
previousAnswers,
true,
transportInputChoice,
options.backendTarget,
options.ui5AbapRepo?.default
);
transportInputChoice = input;
return result;
}
Expand All @@ -61,11 +73,13 @@ export function getTransportRequestPrompts(
when: async (previousAnswers: AbapDeployConfigAnswersInternal): Promise<boolean> => {
if (!PromptState.isYUI) {
const result = await validateTransportChoiceInput(
useStandalone,
previousAnswers.transportInputChoice,
previousAnswers,
false,
undefined,
options.backendTarget
options.backendTarget,
options.ui5AbapRepo?.default
);
if (result !== true) {
throw new Error(result as string);
Expand Down
Loading

0 comments on commit 21d4b13

Please sign in to comment.