@pega/custom-dx-components
Version:
Utility for building custom UI components
60 lines (46 loc) • 1.5 kB
JavaScript
import chalk from 'chalk';
import { addDebugLog, getConfigDefaults } from '../../util.js';
export const getComponentKeyQuestion = async(localComponents, copyMoveLC, paramComponentKey = null) => {
const orAll = localComponents.length > 1 ? "or ALL" : "";
return [
{
name: 'componentKey',
type: 'rawlist',
pageSize: 15,
message: `Select component to ${copyMoveLC} ${orAll}`,
choices: localComponents,
when: () => !paramComponentKey
}
];
}
export const getLibraryQuestions = async (archLibs) => {
addDebugLog("getLibraryQuestions", "", "");
const configDef = getConfigDefaults();
return [
{
name: 'libraryName',
type: 'rawlist',
message: 'Select library to move to',
choices: archLibs
}
];
};
export const getLibraryVersionQuestion = async (libraryName, libVersions, copyOrMove) => {
addDebugLog("getLibraryVersionQuestion", `libraryName: ${libraryName}`, "");
const configDef = getConfigDefaults();
return [
{
name: 'version',
type: 'rawlist',
message: `Select ${chalk.green.bold(`${libraryName}`)} library version to ${copyOrMove} to`,
choices: libVersions
},
{
name: 'copyShared',
type: 'confirm',
message: `Copy ${chalk.yellow.bold("/shared")} directory (same named files will be overridden) ?`,
default: true,
when: (answers) => (answers.version != configDef.buildVersion && libraryName != configDef.library)
},
];
};