@sap-ux/system-access
Version:
Reusable module allowing to access systems using the store or prompts.
65 lines • 1.66 kB
JavaScript
import { AuthenticationType } from '@sap-ux/store';
import { existsSync } from 'node:fs';
const authType = {
type: 'autocomplete',
name: 'authType',
message: 'Type of authentication:',
choices: [
{ title: 'Basic authentication', value: AuthenticationType.Basic },
{ title: 'SAP reentrance tickets', value: AuthenticationType.ReentranceTicket }
]
};
const username = {
type: 'text',
name: 'username',
message: 'Username:'
};
const password = {
type: 'password',
name: 'password',
message: 'Password:'
};
const serviceKeysPath = {
type: 'text',
name: 'path',
message: 'Please provide the service keys as file:',
validate: (input) => existsSync(input)
};
const storeCredentials = {
type: 'confirm',
name: 'store',
message: 'Do you want to store your credentials in the secure storage?',
initial: true
};
const systemName = {
type: 'text',
name: 'name',
message: 'System name:',
validate: (input) => !!input
};
/**
* Export map of questions for usage with the prompts modules
*/
export const questions = {
authType,
username,
password,
serviceKeysPath,
storeCredentials,
systemName
};
/**
* Generate a map of questions for usages with inquirer (e.g. in yeoman)
*/
export const inquirer = {};
for (const key in questions) {
const question = questions[key];
inquirer[key] = {
type: question.type === 'text' ? 'input' : question.type,
name: question.name,
message: question.message,
validate: question.validate,
default: question.initial
};
}
//# sourceMappingURL=prompts.js.map