UNPKG

@pega/custom-dx-components

Version:

Utility for building custom UI components

163 lines (131 loc) 9.26 kB
import chalk from 'chalk'; import { showVersion, getLibraryBased, getLibraryBasedCL } from '../../util.js'; export const showCurrentStatus = async () => { const configDefaults = await getConfigDefaults(); const componentList = await getComponents(); console.log(""); console.log("\tCurrent status"); console.log("\t---------------------"); console.log(`\tOrganization:\t ${chalk.bold.green(`${configDefaults.organization}`)}`); console.log(`\tLibrary:\t ${chalk.bold.green(`${configDefaults.library}`)}`); console.log(`\tVersion:\t ${chalk.bold.green(`${configDefaults.buildVersion}`)}`); if (!configDefaults.devBuild) { console.log(`\tPermanent:\t ${chalk.bold.magentaBright(`${!configDefaults.devBuild}`)}`); } else { console.log(`\tPermanent:\t ${chalk.bold.green(`${!configDefaults.devBuild}`)}`); } console.log(`\tComponent count: ${chalk.bold.green(`${componentList.length}`)}`); console.log(""); } export const showHelpV1 = () => { console.log(""); console.log(`\nnpm run <command>`); console.log(`\nUsage:`); console.log(`\n${chalk.underline(`Authenticate (for Server commands)`)}`); console.log(`${chalk.cyan('npm run authenticate')}\t\tauthenticate to a server`); console.log(`\n${chalk.underline(`Components`)}`); console.log(`${chalk.cyan('npm run create ')}\tcreate a component`); console.log(`${chalk.cyan('npm run createAll ')}\tcreate components of all different types`); console.log(`${chalk.cyan('npm run buildComponent ')}\tvalidate and build a component before publishing, checking for errors`); console.log(`${chalk.cyan('npm run buildAllComponents')}\tvalidate and build ALL components before publishing, checking for errors`); console.log(`${chalk.cyan('npm run rename ')}\trename a component`); console.log(`${chalk.cyan('npm run importComponent ')}\timport a component from a path`); console.log(""); console.log(`${chalk.cyan('npm run startStorybook ')}\tstorybook components for testing`); console.log(`${chalk.cyan('npm run test')}\t\t\trun component unit tests`); console.log(`\n${chalk.underline(`Local and Server (needs authentication)`)}`); console.log(`${chalk.cyan('npm run list ')}\tget list of components`); console.log(`${chalk.cyan('npm run delete ')}\tdelete a component`); console.log(`${chalk.cyan('npm run deleteAll ')}\tdelete ALL components`); console.log(`\n${chalk.underline(`Server (needs authentication)`)}`); console.log(`${chalk.cyan('npm run publish ')}\tpublish a component to server`); console.log(`${chalk.cyan('npm run publishAll ')}\tpublish ALL components to server`); console.log(""); console.log(`\n${chalk.underline(`Notes`)}`); console.log(`${chalk.yellow('>> By choosing to create and use custom components, you agree to keep them up-to-date with every release of Pega Infinity,')}`); console.log(`${chalk.yellow('>> as well as meeting compliance standards for data privacy and accessibility.')}\n`); console.log(`Cannot publish a component with prefix (Org_Lib) that matches a Rule-UI-ComponentLibrary (libraryModeCL) in same ruleset.`); console.log(""); }; export const showHelpV2 = (isCL) => { console.log(""); if (!isCL) { console.log(chalk.yellow("**** Beta capability and subject to change. Developer experimental. Do not use in a Production Deployment. ***\n")); } console.log(`--> All commands will NOT work until a library is created via ${chalk.cyan(`npm run createLib`)} or ${chalk.cyan(`npm run importLibVersion`)}.`); console.log(`\nnpm run <command>`); console.log(`\nUsage:`); console.log(`\n${chalk.underline(`Authenticate (for Server commands)`)}`); console.log(`${chalk.cyan('npm run authenticate')}\t\tauthenticate to a server (required for publish commands)`); console.log(`\n${chalk.underline(`Library`)}`); console.log(`${chalk.cyan('npm run createLib' )}\t\tcreate a new library and version (mandatory)`); console.log(`${chalk.cyan('npm run switchLib' )}\t\tswitch to different library and version`); console.log(`${chalk.cyan('npm run listLib ')}\t\tget contents of library and version`); console.log(`${chalk.cyan('npm run deleteLib ')}\t\tdelete library/version or ALL versions`); console.log(`${chalk.cyan('npm run showStatus')}\t\tshow state of current working library/version`); console.log(`\n${chalk.underline(`Library Versions`)}`); console.log(`${chalk.cyan('npm run createLibVersion')}\tcreate a new version within the current library`); console.log(`${chalk.cyan('npm run switchLibVersion')}\tswitch to different version within the current library`); console.log(`${chalk.cyan('npm run deleteLibVersion')}\tdelete current version, move to another version, delete is permanent`); console.log(`${chalk.cyan('npm run restoreLibVersion ')}\trestores to current version from local storage (current changes will be LOST)`); console.log(`${chalk.cyan('npm run storeLibVersion ')}\tstore current version to local storage (must SAVE components before)`); if (isCL) { console.log(`${chalk.cyan('npm run exportLibVersion')}\texport current version as a zip file to a given local path or a server (must SAVE components before)`); console.log(`${chalk.cyan('npm run importLibVersion')}\timport a zip file (created by export) from a given local path or a server`); } else { console.log(`${chalk.cyan('npm run exportLibVersion')}\texport current version as a zip file to a given local path (must SAVE components before)`); console.log(`${chalk.cyan('npm run importLibVersion')}\timport a zip file (created by export) from a given local path`); console.log(`${chalk.cyan('npm run setPermanent ')}\tmake current version permanent or non permanent upon publish`); } console.log(`\n${chalk.underline(`Published Versions (needs authentication)`)}`); console.log(`${chalk.cyan('npm run publish ')}\tpublish current library/version to server (creates a local published library as well)`); console.log(`${chalk.cyan('npm run listPublishedLib ')}\tget contents of published library/version (local or server)`); console.log(`${chalk.cyan('npm run deletePublishedLib')}\tdelete ALL contents of published library/version (local or server)`); console.log(`\n${chalk.underline(`Components (in current library/version context)`)}`); console.log(`${chalk.cyan('npm run create ')}\t\tcreate a component`); console.log(`${chalk.cyan('npm run createAll ')}\t\tcreate components of all different types`); console.log(`${chalk.cyan('npm run validate ')}\t\tvalidate a component before publishing, checking for errors`); console.log(`${chalk.cyan('npm run validateAll')}\t\tvalidate ALL components before publishing, checking for errors`); console.log(`${chalk.cyan('npm run rename ')}\t\trename a component`); console.log(`${chalk.cyan('npm run move ')}\t\tmove (or copy) single component or ALL in current version to another version or library`); console.log(`${chalk.cyan('npm run importComponent')}\t\timport a component from a path`); console.log(`${chalk.cyan('npm run list ')}\t\tget list of components`); console.log(`${chalk.cyan('npm run delete ')}\t\tdelete a component`); console.log(`${chalk.cyan('npm run deleteAll ')}\t\tdelete ALL components`); console.log(""); console.log(`${chalk.cyan('npm run startStorybook')}\t\tstorybook components for testing`); console.log(`${chalk.cyan('npm run test')}\t\t\trun component unit tests`); if (isCL) { console.log(`${chalk.cyan('npm run startDevServer')}\t\tdebug runtime with browser break points using a local component server`); } console.log(""); console.log(`\n${chalk.underline(`Notes`)}`); console.log(`${chalk.yellow('>> By choosing to create and use custom components, you agree to keep them up-to-date with every release of Pega Infinity,')}`); console.log(`${chalk.yellow('>> as well as meeting compliance standards for data privacy and accessibility.')}\n`); console.log(`The following commands will store existing version in storage before executing the command:`); console.log(`${chalk.cyan(`createLib, switchLib, createLibVersion, switchLibVersion, publish, exportLibVersion, storeLibVersion`)}`); console.log(`\nWhen editing in an IDE, always ${chalk.yellow("SAVE")} changes to components before doing a library/version context switch`); console.log(`or changes will be lost!`); console.log(`\nStoring is to LOCAL storage and is not backed up. You should export your library/versions archives to ${chalk.yellow("git")}`); if (isCL) { console.log(`or export archives to ${chalk.yellow("server")} for backup storage.`); } else { console.log(`for backup storage.`); } console.log(`\nIn tasks.config.json, set ${chalk.yellow("libraryModeCL")} to ${chalk.yellow("false")} for original stand alone components or for ${chalk.yellow("Launchpad")} components.`); console.log(""); } export default async options => { const isLibraryBased = getLibraryBased(); const isLibraryBasedCL = getLibraryBasedCL(); await showVersion(); if (isLibraryBased) { await showHelpV2(isLibraryBasedCL); } else { await showHelpV1(); } }