UNPKG

growthbook

Version:

The GrowthBook command-line interface (CLI) for working with the GrowthBook A/B testing, feature flagging, and experimentation platform

70 lines (69 loc) 2.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.paginationCliFlags = exports.fileInputOutputCliFlags = exports.baseGrowthBookCliFlags = exports.parseBooleanFromString = exports.FALSY_VALUES = exports.TRUTHY_VALUES = exports.Icons = void 0; const chalk = require("chalk"); const core_1 = require("@oclif/core"); const constants_1 = require("./constants"); exports.Icons = { // Green checkmark to be used with ux.action.stop(checkmark) for nicer feedback UI checkmark: chalk.green('✔'), // Red X symbol for sad path feedback xSymbol: chalk.red('𝒙'), }; exports.TRUTHY_VALUES = [1, '1', 'true', 'on']; exports.FALSY_VALUES = [0, '0', 'false', 'off']; /** * Defaults to false if the value cannot be parsed as true * @param value {string | number} * @return boolean value or null */ const parseBooleanFromString = (value) => { if (exports.TRUTHY_VALUES.includes(value.toString().toLowerCase())) return true; if (exports.FALSY_VALUES.includes(value.toString().toLowerCase())) return false; return null; }; exports.parseBooleanFromString = parseBooleanFromString; /** * Base GrowthBook CLI flags for adding support for configurations. */ exports.baseGrowthBookCliFlags = { apiBaseUrl: core_1.Flags.string({ char: 'u', description: `Your GrowthBook instance base URL (e.g. http://localhost:3100, default: ${constants_1.DEFAULT_GROWTHBOOK_BASE_URL})`, required: false, }), profile: core_1.Flags.string({ char: 'p', description: `Optional profile (for projects that use multiple GrowthBook instances) default: ${constants_1.DEFAULT_GROWTHBOOK_PROFILE})`, required: false, }), }; /** * Flags for supporting reading from file and outputting to file */ exports.fileInputOutputCliFlags = { filePath: core_1.Flags.string({ char: 'f', description: 'Path to input file', required: false, }), output: core_1.Flags.string({ char: 'o', description: 'Path to output file, e.g. created-resource.json', required: false, }), }; exports.paginationCliFlags = { limit: core_1.Flags.integer({ description: 'Limit for pagination', required: false, default: 100, }), offset: core_1.Flags.integer({ description: 'Offset for pagination', required: false, default: 0, }), };