UNPKG

bump-cli

Version:

The Bump CLI is used to interact with your API documentation hosted on Bump.sh by using the API of developers.bump.sh

127 lines (126 loc) 4.52 kB
import { Flags } from '@oclif/core'; // Custom flags for bump-cli const doc = Flags.custom({ char: 'd', async default() { const envDoc = process.env.BUMP_ID; if (envDoc) return envDoc; // Search doc id in .bump/config.json file? }, description: 'Documentation public id or slug. Can be provided via BUMP_ID environment variable', }); const docName = Flags.custom({ char: 'n', dependsOn: ['auto-create'], description: 'Documentation name. Used with --auto-create flag.', }); const hub = Flags.custom({ char: 'b', async default() { const envHub = process.env.BUMP_HUB_ID; if (envHub) return envHub; // Search hub id in .bump/config.json file? }, description: 'Hub id or slug. Can be provided via BUMP_HUB_ID environment variable', }); const filenamePattern = Flags.custom({ default: '{slug}-api', description: `Pattern to extract the documentation slug from filenames when deploying a DIRECTORY. Pattern uses only '*' and '{slug}' as special characters to extract the slug from a filename without extension. Used with --hub flag only.`, }); const branch = Flags.custom({ char: 'B', async default() { const envBranch = process.env.BUMP_BRANCH_NAME; if (envBranch) return envBranch; }, description: 'Branch name. Can be provided via BUMP_BRANCH_NAME environment variable', }); const token = Flags.custom({ char: 't', async default() { const envToken = process.env.BUMP_TOKEN; if (envToken) return envToken; }, description: 'Documentation or Hub token. Can be provided via BUMP_TOKEN environment variable', required: true, }); const autoCreate = (opts = {}) => { return Flags.boolean({ ...opts, dependsOn: ['hub'], description: 'Automatically create the documentation if needed (only available with a --hub flag). Documentation name can be provided with --doc-name flag. Default: false', }); }; const interactive = (opts = {}) => { return Flags.boolean({ ...opts, dependsOn: ['hub'], description: "Interactively create a configuration file to deploy a Hub (only available with a --hub flag). This will start an interactive process if you don't have a CLI configuration file. Default: false", }); }; const dryRun = (opts = {}) => { return Flags.boolean({ ...opts, description: 'Validate a new documentation version. Does everything a normal deploy would do except publishing the new version. Useful in automated environments such as test platforms or continuous integration. Default: false', }); }; const open = (opts = {}) => { return Flags.boolean({ ...opts, char: 'o', default: false, }); }; const failOnBreaking = (opts = {}) => { return Flags.boolean({ ...opts, char: 'F', async default() { const envCi = process.env.CI; if (envCi) { return true; } return false; }, description: 'Fail when diff contains a breaking change. Defaults to false locally. In CI environments where the env variable CI=1 is set, it defaults to true.', }); }; const live = (opts = {}) => { return Flags.boolean({ ...opts, char: 'l', default: false, }); }; const preview = (opts = {}) => { return Flags.boolean({ ...opts, char: 'p', default: false, description: 'Generate a preview in your API context. The resulting version is temporary and not visible by your documentation viewers.', }); }; const format = Flags.custom({ char: 'f', default: 'text', description: 'Format in which to provide the diff result', options: ['text', 'markdown', 'json', 'html'], }); const expires = Flags.custom({ char: 'e', description: "Specify a longer expiration date for public diffs (defaults to 1 day). Use iso8601 format to provide a date, or you can use `--expires 'never'` to keep the result live indefinitely.", }); const out = Flags.custom({ char: 'o', description: 'Output file path', }); const overlay = Flags.custom({ char: 'o', description: 'Path or URL of overlay file(s) to apply before deploying', multiple: true, }); export { autoCreate, branch, doc, docName, dryRun, expires, failOnBreaking, filenamePattern, format, hub, interactive, live, open, out, overlay, preview, token, };