Skip to content

Commit

Permalink
fix(abap-deploy-config-inquirer ): fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
longieirl committed Oct 14, 2024
2 parents 025b4b2 + 0a271d8 commit aa433e9
Show file tree
Hide file tree
Showing 45 changed files with 612 additions and 253 deletions.
24 changes: 24 additions & 0 deletions examples/ui-prompting-examples/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# @sap-ux-private/ui-prompting-examples

## 0.2.6

### Patch Changes

- Updated dependencies [4c6f92c]
- @sap-ux/ui-components@1.18.9
- @sap-ux/ui-prompting@0.2.6

## 0.2.5

### Patch Changes

- Updated dependencies [b669796]
- @sap-ux/ui-components@1.18.8
- @sap-ux/ui-prompting@0.2.5

## 0.2.4

### Patch Changes

- Updated dependencies [e65bb7f]
- @sap-ux/ui-components@1.18.7
- @sap-ux/ui-prompting@0.2.4

## 0.2.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/ui-prompting-examples/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sap-ux-private/ui-prompting-examples",
"version": "0.2.3",
"version": "0.2.6",
"description": "This project contains UI storybook stories with exampleS with prompt ui and FPM based building blocks.",
"license": "Apache-2.0",
"private": true,
Expand Down
12 changes: 12 additions & 0 deletions packages/abap-deploy-config-inquirer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @sap-ux/abap-deploy-config-inquirer

## 1.0.1

### Patch Changes

- 43988ca: bug fix

## 1.0.0

### Major Changes

- b3b1082: update prompt options for abap deploy config inquirer

## 0.0.25

### 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": "0.0.25",
"version": "1.0.1",
"license": "Apache-2.0",
"main": "dist/index.js",
"scripts": {
Expand Down
20 changes: 2 additions & 18 deletions packages/abap-deploy-config-inquirer/src/prompts/conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,9 @@ export function showPasswordQuestion(): boolean {
/**
* Determines if the UI5 app deploy config question should be shown (UI5 Abap Repo name & Description).
*
* @param hideUi5AbapRepoPrompt - option to hide the prompt if using a btp system
* @returns boolean
*/
export function showUi5AppDeployConfigQuestion(hideUi5AbapRepoPrompt?: boolean): boolean {
if (hideUi5AbapRepoPrompt) {
return false;
}
export function showUi5AppDeployConfigQuestion(): boolean {
return !PromptState.transportAnswers.transportConfigNeedsCreds;
}

Expand Down Expand Up @@ -301,18 +297,6 @@ export function defaultOrShowManualTransportQuestion(transportInputChoice?: stri
* @returns boolean
*/
export function showIndexQuestion(options: AbapDeployConfigPromptOptions): boolean {
const condition = Boolean(options.indexGenerationAllowed && !PromptState.abapDeployConfig.index);
const condition = Boolean(options.index?.indexGenerationAllowed && !PromptState.abapDeployConfig.index);
return condition && !PromptState.transportAnswers.transportConfigError && options.backendTarget?.type !== 'library';
}

/**
* Determines if the overwrite prompt should be shown.
*
* @param options - abap deploy config prompt options
* @returns boolean
*/
export function showOverwriteQuestion(options: AbapDeployConfigPromptOptions): boolean {
return Boolean(
options.showOverwriteQuestion && !!options.existingDeployTaskConfig && !PromptState.abapDeployConfig.overwrite
);
}
6 changes: 4 additions & 2 deletions packages/abap-deploy-config-inquirer/src/prompts/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ async function getBackendTargetChoices(
const systemChoices: AbapSystemChoice[] = Object.values(backendSystems)
.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true, caseFirst: 'lower' }))
.map((system) => {
if (!targetExists) {
targetExists = system.url === target?.url && (system.client ?? '') === (target?.client ?? '');
if (!targetExists && target?.url) {
targetExists =
system.url.replace(/\/$/, '') === target.url.replace(/\/$/, '') &&
(system.client ?? '') === (target?.client ?? '');
}
return {
name: targetExists
Expand Down
16 changes: 7 additions & 9 deletions packages/abap-deploy-config-inquirer/src/prompts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,17 @@ export async function getAbapDeployConfigQuestions(

const targetPrompts = await getAbapTargetPrompts(options);
const authPrompts = getAuthPrompts(options);
const appConfigPrompts = getAppConfigPrompts(options);
const questions = [...targetPrompts, ...authPrompts];

if (options.ui5AbapRepo?.hide !== true) {
questions.push(...getAppConfigPrompts(options));
}

const packagePrompts = getPackagePrompts(options);
const transportRequestPrompts = getTransportRequestPrompts(options);
const confirmPrompts = getConfirmPrompts(options);

const questions = [
...targetPrompts,
...authPrompts,
...appConfigPrompts,
...packagePrompts,
...transportRequestPrompts,
...confirmPrompts
];
questions.push(...packagePrompts, ...transportRequestPrompts, ...confirmPrompts);

return questions as AbapDeployConfigQuestion[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { PromptState } from '../prompt-state';
import { Severity, type IMessageSeverity } from '@sap-devx/yeoman-ui-types';
import { isAppStudio, isOnPremiseDestination, type Destinations } from '@sap-ux/btp-utils';
import {
abapDeployConfigInternalPromptNames,
promptNames,
ClientChoiceValue,
type AbapDeployConfigAnswersInternal,
type AbapDeployConfigPromptOptions,
Expand Down Expand Up @@ -44,7 +44,7 @@ function getDestinationPrompt(
{
when: (): boolean => isAppStudio(),
type: 'list',
name: abapDeployConfigInternalPromptNames.destination,
name: promptNames.destination,
message: t('prompts.target.destination.message'),
guiOptions: {
mandatory: true,
Expand All @@ -70,13 +70,13 @@ function getDestinationPrompt(
if (isAppStudio() && !PromptState.isYUI) {
prompts.push({
when: (answers: AbapDeployConfigAnswersInternal): boolean => {
const destination = answers[abapDeployConfigInternalPromptNames.destination];
const destination = answers[promptNames.destination];
if (destination) {
updateDestinationPromptState(destination, destinations);
}
return false;
},
name: abapDeployConfigInternalPromptNames.destinationCliSetter
name: promptNames.destinationCliSetter
} as Question);
}
return prompts;
Expand All @@ -95,7 +95,7 @@ function getTargetSystemPrompt(
{
when: (): boolean => !isAppStudio(),
type: 'list',
name: abapDeployConfigInternalPromptNames.targetSystem,
name: promptNames.targetSystem,
message: t('prompts.target.targetSystem.message'),
guiOptions: {
mandatory: true,
Expand All @@ -110,13 +110,13 @@ function getTargetSystemPrompt(
if (!isAppStudio() && !PromptState.isYUI) {
prompts.push({
when: (answers: AbapDeployConfigAnswersInternal): boolean => {
const target = answers[abapDeployConfigInternalPromptNames.targetSystem];
const target = answers[promptNames.targetSystem];
if (target) {
validateTargetSystemUrlCli(target, choices);
}
return false;
},
name: abapDeployConfigInternalPromptNames.targetSystemCliSetter
name: promptNames.targetSystemCliSetter
} as Question);
}
return prompts;
Expand All @@ -140,7 +140,7 @@ function getUrlPrompt(
return isValid;
},
type: 'input',
name: abapDeployConfigInternalPromptNames.url,
name: promptNames.url,
message: t('prompts.target.url.message'),
guiOptions: {
mandatory: true,
Expand All @@ -163,7 +163,7 @@ function getScpPrompt(backendTarget?: BackendTarget): Question<AbapDeployConfigA
{
when: (previousAnswers: AbapDeployConfigAnswersInternal): boolean => showScpQuestion(previousAnswers),
type: 'confirm',
name: abapDeployConfigInternalPromptNames.scp,
name: promptNames.scp,
message: t('prompts.target.scp.message'),
guiOptions: {
breadcrumb: t('prompts.target.scp.breadcrumb')
Expand All @@ -174,15 +174,14 @@ function getScpPrompt(backendTarget?: BackendTarget): Question<AbapDeployConfigA
// Setter prompt to ensure the state for both CLI and YUI is updated
prompts.push({
when: (answers: AbapDeployConfigAnswersInternal): boolean => {
const scpChoice = answers[abapDeployConfigInternalPromptNames.scp];
const targetChoice = answers[abapDeployConfigInternalPromptNames.targetSystem];
const scpChoice = answers[promptNames.scp];
const targetChoice = answers[promptNames.targetSystem];
// scpChoice by default is true so only update state if target system is a URL
PromptState.abapDeployConfig.scp = !!(targetChoice === TargetSystemType.Url && scpChoice);
return false;
},
name: abapDeployConfigInternalPromptNames.scpSetter
name: promptNames.scpSetter
} as Question);

return prompts;
}

Expand All @@ -200,7 +199,7 @@ function getClientChoicePrompt(
when: (previousAnswers: AbapDeployConfigAnswersInternal): boolean =>
showClientChoiceQuestion(previousAnswers, backendTarget?.abapTarget?.client),
type: 'list',
name: abapDeployConfigInternalPromptNames.clientChoice,
name: promptNames.clientChoice,
message: t('prompts.target.clientChoice.message'),
guiOptions: {
applyDefaultWhenDirty: true
Expand All @@ -216,13 +215,13 @@ function getClientChoicePrompt(
if (!PromptState.isYUI) {
prompts.push({
when: (answers: AbapDeployConfigAnswersInternal): boolean => {
const clientChoice = answers[abapDeployConfigInternalPromptNames.clientChoice];
const clientChoice = answers[promptNames.clientChoice];
if (clientChoice) {
validateClientChoiceQuestion(clientChoice as ClientChoiceValue, backendTarget?.abapTarget?.client);
}
return false;
},
name: abapDeployConfigInternalPromptNames.clientChoiceCliSetter
name: promptNames.clientChoiceCliSetter
} as Question);
}
return prompts;
Expand All @@ -239,7 +238,7 @@ function getClientPrompt(): Question<AbapDeployConfigAnswersInternal> {
return showClientQuestion(previousAnswers);
},
type: 'input',
name: abapDeployConfigInternalPromptNames.client,
name: promptNames.client,
message: t('prompts.target.client.message'),
guiOptions: {
breadcrumb: t('prompts.target.client.breadcrumb')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { t } from '../../i18n';
import { showPasswordQuestion, showUsernameQuestion } from '../conditions';
import { validateCredentials } from '../validators';
import {
abapDeployConfigInternalPromptNames,
type AbapDeployConfigAnswersInternal,
type AbapDeployConfigPromptOptions
} from '../../types';
import { promptNames, type AbapDeployConfigAnswersInternal, type AbapDeployConfigPromptOptions } from '../../types';
import type { InputQuestion, PasswordQuestion, Question } from 'inquirer';

/**
Expand All @@ -18,7 +14,7 @@ function getUsernamePrompt(options: AbapDeployConfigPromptOptions): Question<Aba
return {
when: (): Promise<boolean> => showUsernameQuestion(options.backendTarget),
type: 'input',
name: abapDeployConfigInternalPromptNames.username,
name: promptNames.username,
message: t('prompts.auth.username.message'),
guiOptions: {
mandatory: true
Expand All @@ -36,7 +32,7 @@ function getPasswordPrompt(options: AbapDeployConfigPromptOptions): Question<Aba
return {
when: (): boolean => showPasswordQuestion(),
type: 'password',
name: abapDeployConfigInternalPromptNames.password,
name: promptNames.password,
message: t('prompts.auth.password.message'),
mask: '*',
guiOptions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { showUi5AppDeployConfigQuestion } from '../../conditions';
import { validateAppDescription, validateUi5AbapRepoName } from '../../validators';
import { PromptState } from '../../prompt-state';
import { t } from '../../../i18n';
import {
abapDeployConfigInternalPromptNames,
type AbapDeployConfigAnswersInternal,
type AbapDeployConfigPromptOptions
} from '../../../types';
import { promptNames, type AbapDeployConfigAnswersInternal, type AbapDeployConfigPromptOptions } from '../../../types';
import type { InputQuestion, Question } from 'inquirer';

/**
Expand All @@ -17,9 +13,9 @@ import type { InputQuestion, Question } from 'inquirer';
*/
function getUi5AbapRepoPrompt(options: AbapDeployConfigPromptOptions): Question<AbapDeployConfigAnswersInternal> {
return {
when: (): boolean => showUi5AppDeployConfigQuestion(options.hideUi5AbapRepoPrompt),
when: (): boolean => showUi5AppDeployConfigQuestion(),
type: 'input',
name: abapDeployConfigInternalPromptNames.ui5AbapRepo,
name: promptNames.ui5AbapRepo,
message: (): string => {
return PromptState.transportAnswers.transportConfig?.getApplicationPrefix()
? t('prompts.config.app.ui5AbapRepo.messageMaxLength', {
Expand All @@ -33,7 +29,7 @@ function getUi5AbapRepoPrompt(options: AbapDeployConfigPromptOptions): Question<
breadcrumb: t('prompts.config.app.ui5AbapRepo.message')
},
default: (previousAnswers: AbapDeployConfigAnswersInternal) =>
previousAnswers.ui5AbapRepo || options.existingDeployTaskConfig?.name,
previousAnswers.ui5AbapRepo || options.ui5AbapRepo?.default,
validate: (input: string): string | boolean => validateUi5AbapRepoName(input),
filter: (input: string): string | undefined =>
!PromptState.isYUI ? input?.trim()?.toUpperCase() : input?.trim()
Expand All @@ -48,16 +44,16 @@ function getUi5AbapRepoPrompt(options: AbapDeployConfigPromptOptions): Question<
*/
function getDescriptionPrompt(options: AbapDeployConfigPromptOptions): Question<AbapDeployConfigAnswersInternal> {
return {
when: (): boolean => showUi5AppDeployConfigQuestion(options.hideUi5AbapRepoPrompt),
when: (): boolean => showUi5AppDeployConfigQuestion(),
type: 'input',
name: abapDeployConfigInternalPromptNames.description,
name: promptNames.description,
message: t('prompts.config.app.description.message'),
guiOptions: {
hint: t('prompts.config.app.description.hint'),
breadcrumb: true
},
default: (previousAnswers: AbapDeployConfigAnswersInternal): string | undefined =>
previousAnswers.description || options.existingDeployTaskConfig?.description,
previousAnswers.description || options.description?.default,
filter: (input: string): string | undefined => input?.trim(),
validate: (input: string): boolean | string => validateAppDescription(input)
} as InputQuestion<AbapDeployConfigAnswersInternal>;
Expand Down
Loading

0 comments on commit aa433e9

Please sign in to comment.