UNPKG

@pega/custom-dx-components

Version:

Utility for building custom UI components

131 lines (101 loc) 7.02 kB
import fs from 'fs'; import path from 'path'; import chalk from 'chalk'; import { showVersion, getLibraryBased } 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(`${chalk.cyan('npm run startStorybook ')}\tstorybook components for testing`); 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(""); }; export const showHelpV2 = () => { console.log(""); 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`)}.`); console.log(`\nnpm run <command>`); console.log(`\nUsage:`); console.log(`\n${chalk.underline(`Authenticate`)}`); 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`); console.log(`${chalk.cyan('npm run storeLibVersion ')}\tstore current version to local storage (must SAVE components before)`); 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 libary/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(`${chalk.cyan('npm run startStorybook')}\t\tstorybook components for testing`); console.log(""); console.log(`\n${chalk.underline(`Notes`)}`); console.log(`The following commands will store existing version in storage before executing the command:`); console.log(`${chalk.cyan(`createLib, switchLib, createLibVersion, switchLibVersion, publishLibVersion, exportLibVersion`)}`); 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(""); } export default async options => { const isLibraryBased = getLibraryBased(); await showVersion(); if (isLibraryBased) { await showHelpV2(); } else { await showHelpV1(); } }