Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into Add_madge
Browse files Browse the repository at this point in the history
* origin/main:
  fix(abap-deploy-config): fix for local pkg verification (#2289)
  chore: apply latest changesets
  feat(`odata-service-inquirer`): Adds new system prompting (#2267)
  • Loading branch information
devinea committed Aug 27, 2024
2 parents 32d7998 + fc58821 commit 0750fcb
Show file tree
Hide file tree
Showing 40 changed files with 2,203 additions and 545 deletions.
5 changes: 5 additions & 0 deletions .changeset/nine-weeks-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sap-ux/abap-deploy-config-inquirer': patch
---

fix for local package verification
2 changes: 1 addition & 1 deletion packages/abap-deploy-config-inquirer/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const ABAP_PACKAGE_SEARCH_MAX_RESULTS = 50;
export const DEFAULT_PACKAGE_ABAP = '$tmp';
export const DEFAULT_PACKAGE_ABAP = '$TMP';
export const CREATE_TR_DURING_DEPLOY = 'REPLACE_WITH_TRANSPORT';
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ export async function validatePackage(
};

// checks if package is a local package and will update prompt state accordingly
await getTransportListFromService(input, answers.ui5AbapRepo ?? '', systemConfig, backendTarget);
await getTransportListFromService(input.toUpperCase(), answers.ui5AbapRepo ?? '', systemConfig, backendTarget);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('defaults', () => {
} as unknown as TransportConfig;

defaultPkg = defaultPackage();
expect(defaultPkg).toBe('$tmp');
expect(defaultPkg).toBe('$TMP');
});

it('should return default transport request choice', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ import {
} from '../../src/types';
import * as utils from '../../src/utils';
import { mockDestinations } from '../fixtures/destinations';
import * as serviceProviderUtils from '../../src/service-provider-utils';

jest.mock('../../src/service-provider-utils', () => ({
getTransportListFromService: jest.fn()
}));

describe('Test validators', () => {
beforeAll(async () => {
Expand Down Expand Up @@ -276,8 +281,13 @@ describe('Test validators', () => {

describe('validatePackage', () => {
it('should return error for invalid package input', async () => {
const result = await validatePackage('ZPACKAGE', {});
const getTransportListFromServiceSpy = jest.spyOn(serviceProviderUtils, 'getTransportListFromService');

const result = await validatePackage('zpackage', {
ui5AbapRepo: 'ZUI5REPO'
});
expect(result).toBe(true);
expect(getTransportListFromServiceSpy).toBeCalledWith('ZPACKAGE', 'ZUI5REPO', {}, undefined);
});
it('should return error for invalid package input', async () => {
const result = await validatePackage(' ', {});
Expand Down
7 changes: 7 additions & 0 deletions packages/cap-config-writer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @sap-ux/cap-config-writer

## 0.7.29

### Patch Changes

- Updated dependencies [34b2606]
- @sap-ux/odata-service-inquirer@0.5.29

## 0.7.28

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cap-config-writer/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sap-ux/cap-config-writer",
"description": "Add or update configuration for SAP CAP projects",
"version": "0.7.28",
"version": "0.7.29",
"repository": {
"type": "git",
"url": "https://github.com/SAP/open-ux-tools.git",
Expand Down
6 changes: 6 additions & 0 deletions packages/create/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sap-ux/create

## 0.7.61

### Patch Changes

- @sap-ux/cap-config-writer@0.7.29

## 0.7.60

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/create/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sap-ux/create",
"description": "SAP Fiori tools module to add or remove features",
"version": "0.7.60",
"version": "0.7.61",
"repository": {
"type": "git",
"url": "https://github.com/SAP/open-ux-tools.git",
Expand Down
6 changes: 6 additions & 0 deletions packages/odata-service-inquirer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sap-ux/odata-service-inquirer

## 0.5.29

### Patch Changes

- 34b2606: Adds new system prompts for Abap on BTP

## 0.5.28

### Patch Changes
Expand Down
3 changes: 2 additions & 1 deletion packages/odata-service-inquirer/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sap-ux/odata-service-inquirer",
"description": "Prompts module that can prompt users for inputs required for odata service writing",
"version": "0.5.28",
"version": "0.5.29",
"repository": {
"type": "git",
"url": "https://github.com/SAP/open-ux-tools.git",
Expand Down Expand Up @@ -30,6 +30,7 @@
"!dist/**/*.map"
],
"dependencies": {
"@sap/cf-tools": "3.2.0",
"@sap-ux/axios-extension": "workspace:*",
"@sap-ux/btp-utils": "workspace:*",
"@sap-ux/guided-answers-helper": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,22 +339,22 @@ export class ErrorHandler {
* Used by validate functions to report in-line user friendly errors.
* Checks if there is an existing error.
*
* @param error optional, if provided get the end user message that it maps to, otherwise get the previous error message
* @param reset optional, resets the previous error state if true
* @param error optional, if provided get the end user message that it maps to, otherwise get the previous error message, if a boolean is passed it will be interpreted as `reset`.
* @param reset optional, resets the previous error state if true, if error is omitted reset may be passed as the first argument
* @param fallback optional, return the message of the specified ERROR_TYPE if no previous end user message and no error specified
* @returns The error message
*/
public getErrorMsg(error?: any, reset?: boolean, fallback?: ERROR_TYPE): string | undefined {
let errorMsg;
if (error) {
if (error && typeof error !== 'boolean') {
errorMsg = ErrorHandler.mapErrorToMsg(error).errorMsg;
}
// Get previous error message
if (!errorMsg) {
errorMsg = this.currentErrorMsg ?? (fallback ? ErrorHandler.getErrorMsgFromType(fallback) : undefined);
}

if (reset) {
if (error === true || reset) {
this.currentErrorMsg = null;
this.currentErrorType = null;
}
Expand Down
35 changes: 5 additions & 30 deletions packages/odata-service-inquirer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import { type InquirerAdapter } from '@sap-ux/inquirer-common';
import { type Logger } from '@sap-ux/logger';
import { OdataVersion } from '@sap-ux/odata-service-writer';
import { type ToolsSuiteTelemetryClient } from '@sap-ux/telemetry';
import type { Question } from 'inquirer';
import autocomplete from 'inquirer-autocomplete-prompt';
import { ERROR_TYPE, ErrorHandler } from './error-handler/error-handler';
import { initI18nOdataServiceInquirer } from './i18n';
import { getQuestions } from './prompts';
import type { AbapOnPremAnswers } from './prompts/datasources/sap-system/abap-on-prem/questions';
import { getAbapOnPremSystemQuestions } from './prompts/datasources/sap-system/abap-on-prem/questions';
import { newSystemChoiceValue } from './prompts/datasources/sap-system/new-system/questions';
import LoggerHelper from './prompts/logger-helper';
import {
Expand All @@ -19,8 +16,7 @@ import {
type OdataServiceAnswers,
type OdataServicePromptOptions,
type OdataServiceQuestion,
type SapSystemType,
type SystemNamePromptOptions
type SapSystemType
} from './types';
import { PromptState, setTelemetryClient } from './utils';

Expand Down Expand Up @@ -89,40 +85,19 @@ async function prompt(
return answers;
}

/**
* Get the prompts for an abap on premise system. This can be used to create a new system connection.
*
* @param systemNamePromptOptions options for the system name prompt see {@link SystemNamePromptOptions}
* @param logger a logger compatible with the {@link Logger} interface
* @returns questions for creating a new abap on prem system connection
*/
async function getAbapOnPremSystemPrompts(
systemNamePromptOptions: SystemNamePromptOptions,
logger?: Logger
): Promise<Question<AbapOnPremAnswers>[]> {
if (logger) {
LoggerHelper.logger = logger;
}
// prompt texts must be loaded before the prompts are created, wait for the i18n bundle to be initialized
await initI18nOdataServiceInquirer();
return getAbapOnPremSystemQuestions(systemNamePromptOptions);
}

export {
DatasourceType,
ERROR_TYPE,
ErrorHandler,
OdataVersion,
getAbapOnPremSystemPrompts,
getPrompts,
newSystemChoiceValue,
prompt,
promptNames,
type CapRuntime,
type CapService,
type InquirerAdapter,
type OdataServiceAnswers,
type OdataServicePromptOptions,
type SapSystemType,
// These exports are to facilitate migration to open-ux-tools and will be removed in a future release
newSystemChoiceValue,
ERROR_TYPE,
ErrorHandler
type SapSystemType
};
Loading

0 comments on commit 0750fcb

Please sign in to comment.