diff --git a/bin/bumpp.js b/bin/bumpp.js index be608ce..1dbace3 100644 --- a/bin/bumpp.js +++ b/bin/bumpp.js @@ -1,4 +1,4 @@ #!/usr/bin/env node 'use strict' const { main } = require('../dist/cli') -main(process.argv.slice(2)) +main() diff --git a/src/cli/help.ts b/src/cli/help.ts deleted file mode 100644 index dc55a43..0000000 --- a/src/cli/help.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { description, name, version } from '../../package.json' - -/** - * Text explaining how to use the CLI - */ -export const usageText = ` -Usage: bumpp [release] [options] [files...] - -release: - The release version or type. Can be one of the following: - - A semver version number (ex: 1.23.456) - - prompt: Prompt for the version number (this is the default) - - major: Increase major version - - minor: Increase minor version - - patch: Increase patch version - - premajor: Increase major version, pre-release - - preminor: Increase preminor version, pre-release - - prepatch: Increase prepatch version, pre-release - - prerelease: Increase prerelease version - -options: - --preid The identifier for prerelease versions. - Defaults to "beta". - - -c, --commit [message] Commit changed files to Git. - Defaults to "release vX.X.X". - - -t, --tag [tag] Tag the commit in Git. - The Default tag is "vX.X.X" - - -p, --push Push the Git commit. - - -a, --all Commit/tag/push ALL pending files, - not just the ones that were bumped. - (same as "git commit -a") - - --no-verify Bypass Git commit hooks - (same as "git commit --no-verify") - - -v, --version Show the version number - - -x, --execute Excute additional command after bumping and before commiting - - -q, --quiet Suppress unnecessary output - - -h, --help Show usage information - - --ignore-scripts Bypass version scripts - -files... - One or more files and/or globs to bump (ex: README.md *.txt docs/**/*). - Defaults to package.json and package-lock.json. - -Examples: - - bumpp patch - - Bumps the patch version number in package.json and package-lock.json. - Nothing is committed to git. - - bumpp major --commit - - Bumps the major version number in package.json and package-lock.json. - Commits package.json and package-lock.json to git, but does not tag the commit. - - bumpp -tpa README.md - - Prompts for the new version number and updates package.json, package-lock.json, and README.md. - Commits ALL modified files to git, tags the commit, and pushes the commit. - - bumpp 4.27.9934 --tag "Version " bower.json docs/**/*.md - - Sets the version number to 4.27.9934 in package.json, package-lock.json, bower.json, - and all markdown files in the "docs" directory. Commits the updated files to git, - and tags the commit as "Version 4.27.9934". -` - -/** - * Text describing the program and how to use it - */ -export const helpText = ` -${name} v${version} - ${description} -${usageText}` diff --git a/src/cli/index.ts b/src/cli/index.ts index 7b0226c..d7a13b3 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -4,7 +4,6 @@ import type { VersionBumpProgress } from '../types/version-bump-progress' import { ProgressEvent } from '../types/version-bump-progress' import { versionBump } from '../version-bump' import { ExitCode } from './exit-code' -import { helpText } from './help' import { parseArgs } from './parse-args' /** @@ -12,18 +11,16 @@ import { parseArgs } from './parse-args' * * @param args - The command-line arguments (e.g. ["major", "--preid=alpha", "-ctpa"]) */ -export async function main(args: string[]): Promise { +export async function main(): Promise { try { // Setup global error handlers process.on('uncaughtException', errorHandler) process.on('unhandledRejection', errorHandler) // Parse the command-line arguments - const { help, version, quiet, options } = parseArgs(args) + const { help, version, quiet, options } = parseArgs() if (help) { - // Show the help text and exit - console.log(helpText) process.exit(ExitCode.Success) } else if (version) { diff --git a/src/cli/parse-args.ts b/src/cli/parse-args.ts index 4830e86..03bce80 100644 --- a/src/cli/parse-args.ts +++ b/src/cli/parse-args.ts @@ -4,7 +4,6 @@ import { isReleaseType } from '../release-type' import type { VersionBumpOptions } from '../types/version-bump-options' import { version } from '../../package.json' import { ExitCode } from './exit-code' -import { usageText } from './help' /** * The parsed command-line arguments @@ -19,7 +18,7 @@ export interface ParsedArgs { /** * Parses the command-line arguments */ -export function parseArgs(argv: string[]): ParsedArgs { +export function parseArgs(): ParsedArgs { try { const cli = cac('bumpp') @@ -39,7 +38,8 @@ export function parseArgs(argv: string[]): ParsedArgs { .option('-x, --execute ', 'Commands to execute after version bumps') .help() - const args = cli.parse(argv).options + const result = cli.parse() + const args = result.options const parsedArgs: ParsedArgs = { help: args.help as boolean, @@ -79,6 +79,5 @@ export function parseArgs(argv: string[]): ParsedArgs { function errorHandler(error: Error): never { console.error(error.message) - console.error(usageText) return process.exit(ExitCode.InvalidArgument) } diff --git a/src/cli/run.ts b/src/cli/run.ts index 85d16a4..790e895 100644 --- a/src/cli/run.ts +++ b/src/cli/run.ts @@ -1,3 +1,3 @@ import { main } from '.' -main(process.argv.slice(2)) +main()