diff --git a/package.json b/package.json index 2cd3cf3..38472b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "bumpp", "version": "7.2.0", + "packageManager": "pnpm@7.2.1", "description": "Automatically (or with prompts) bump your version number, commit changes, tag, and push to Git", "keywords": [ "version", @@ -38,7 +39,7 @@ "lint": "eslint src test", "build": "tsup src/index.ts src/cli/index.ts --format esm,cjs --dts --clean", "watch": "npm run build -- --watch src", - "start": "esno src/cli/dev.ts", + "start": "esno src/cli/run.ts", "test": "mocha && npm run lint", "coverage": "nyc node_modules/mocha/bin/mocha", "upgrade": "npm-check -u && npm audit fix", @@ -50,7 +51,6 @@ "@jsdevtools/chai-exec": "^2.1.1", "@jsdevtools/eslint-config": "^1.1.4", "@types/chai": "^4.2.21", - "@types/command-line-args": "^5.2.0", "@types/inquirer": "^7.3.3", "@types/mocha": "^8.2.3", "@types/node": "^14.17.14", @@ -72,8 +72,8 @@ }, "dependencies": { "@jsdevtools/ez-spawn": "^3.0.4", + "cac": "^6.7.12", "chalk": "^4.1.2", - "command-line-args": "^5.2.0", "globby": "^11.0.4", "prompts": "^2.4.1", "semver": "^7.3.5" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4a78277..466cd71 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,19 +1,18 @@ -lockfileVersion: 5.3 +lockfileVersion: 5.4 specifiers: '@jsdevtools/chai-exec': ^2.1.1 '@jsdevtools/eslint-config': ^1.1.4 '@jsdevtools/ez-spawn': ^3.0.4 '@types/chai': ^4.2.21 - '@types/command-line-args': ^5.2.0 '@types/inquirer': ^7.3.3 '@types/mocha': ^8.2.3 '@types/node': ^14.17.14 '@types/prompts': ^2.0.14 '@types/semver': ^7.3.8 + cac: ^6.7.12 chai: ^4.3.4 chalk: ^4.1.2 - command-line-args: ^5.2.0 detect-indent: ^7.0.0 detect-newline: ^3.1.0 eslint: ^7.32.0 @@ -32,17 +31,16 @@ specifiers: dependencies: '@jsdevtools/ez-spawn': 3.0.4 + cac: 6.7.12 chalk: 4.1.2 - command-line-args: 5.2.0 globby: 11.0.4 prompts: 2.4.2 semver: 7.3.5 devDependencies: '@jsdevtools/chai-exec': 2.1.1 - '@jsdevtools/eslint-config': 1.1.4_eslint@7.32.0+typescript@4.5.4 + '@jsdevtools/eslint-config': 1.1.4_ek2rpc4knwwiwkb7dlup4o3xyy '@types/chai': 4.3.0 - '@types/command-line-args': 5.2.0 '@types/inquirer': 7.3.3 '@types/mocha': 8.2.3 '@types/node': 14.18.3 @@ -228,6 +226,8 @@ packages: resolution: {integrity: sha512-Gr86ujcNuPDnNOY8mi383Hvi8IYrJVJYuf3XcuBM/Dgd+bINn/7tHqsj+tKkoreMbmGsFLsltI/JJd8fOFWGDQ==} engines: {node: '>=6.0.0'} hasBin: true + dependencies: + '@babel/types': 7.16.0 dev: true /@babel/template/7.16.0: @@ -320,14 +320,14 @@ packages: '@jsdevtools/ez-spawn': 3.0.4 dev: true - /@jsdevtools/eslint-config/1.1.4_eslint@7.32.0+typescript@4.5.4: + /@jsdevtools/eslint-config/1.1.4_ek2rpc4knwwiwkb7dlup4o3xyy: resolution: {integrity: sha512-Q4LI11Z2duYcKt0VXOnc3TA2JpK9s8LEA6s+45k2g5hNRGAmCCrAcIFrR0unhJt7DDcQ6qfYdXSLaYmSiLnlNA==} engines: {node: '>=10'} peerDependencies: eslint: '>=7' dependencies: - '@typescript-eslint/eslint-plugin': 3.10.1_808c434a99907a635c3e4994b850e8c5 - '@typescript-eslint/parser': 3.10.1_eslint@7.32.0+typescript@4.5.4 + '@typescript-eslint/eslint-plugin': 3.10.1_qcgegsuzsb5ggxb6jgklquhiyu + '@typescript-eslint/parser': 3.10.1_ek2rpc4knwwiwkb7dlup4o3xyy eslint: 7.32.0 eslint-plugin-jsdoc: 30.7.13_eslint@7.32.0 transitivePeerDependencies: @@ -366,10 +366,6 @@ packages: resolution: {integrity: sha512-/ceqdqeRraGolFTcfoXNiqjyQhZzbINDngeoAq9GoHa8PPK1yNzTaxWjA6BFWp5Ua9JpXEMSS4s5i9tS0hOJtw==} dev: true - /@types/command-line-args/5.2.0: - resolution: {integrity: sha512-UuKzKpJJ/Ief6ufIaIzr3A/0XnluX7RvFgwkV89Yzvm77wCh1kFaFmqN8XEnGcN62EuHdedQjEMb8mYxFLGPyA==} - dev: true - /@types/eslint-visitor-keys/1.0.0: resolution: {integrity: sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==} dev: true @@ -385,6 +381,12 @@ packages: resolution: {integrity: sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==} dev: true + /@types/keyv/3.1.4: + resolution: {integrity: sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==} + dependencies: + '@types/node': 14.18.3 + dev: true + /@types/mocha/8.2.3: resolution: {integrity: sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw==} dev: true @@ -399,6 +401,12 @@ packages: '@types/node': 14.18.3 dev: true + /@types/responselike/1.0.0: + resolution: {integrity: sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==} + dependencies: + '@types/node': 14.18.3 + dev: true + /@types/semver/7.3.9: resolution: {integrity: sha512-L/TMpyURfBkf+o/526Zb6kd/tchUP3iBDEPjqjb+U2MAJhVRxxrmr2fwpe08E7QsV7YLcpq0tUaQ9O9x97ZIxQ==} dev: true @@ -409,7 +417,7 @@ packages: '@types/node': 14.18.3 dev: true - /@typescript-eslint/eslint-plugin/3.10.1_808c434a99907a635c3e4994b850e8c5: + /@typescript-eslint/eslint-plugin/3.10.1_qcgegsuzsb5ggxb6jgklquhiyu: resolution: {integrity: sha512-PQg0emRtzZFWq6PxBcdxRH3QIQiyFO3WCVpRL3fgj5oQS3CDs3AeAKfv4DxNhzn8ITdNJGJ4D3Qw8eAJf3lXeQ==} engines: {node: ^10.12.0 || >=12.0.0} peerDependencies: @@ -420,8 +428,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/experimental-utils': 3.10.1_eslint@7.32.0+typescript@4.5.4 - '@typescript-eslint/parser': 3.10.1_eslint@7.32.0+typescript@4.5.4 + '@typescript-eslint/experimental-utils': 3.10.1_ek2rpc4knwwiwkb7dlup4o3xyy + '@typescript-eslint/parser': 3.10.1_ek2rpc4knwwiwkb7dlup4o3xyy debug: 4.3.3 eslint: 7.32.0 functional-red-black-tree: 1.0.1 @@ -433,7 +441,7 @@ packages: - supports-color dev: true - /@typescript-eslint/experimental-utils/3.10.1_eslint@7.32.0+typescript@4.5.4: + /@typescript-eslint/experimental-utils/3.10.1_ek2rpc4knwwiwkb7dlup4o3xyy: resolution: {integrity: sha512-DewqIgscDzmAfd5nOGe4zm6Bl7PKtMG2Ad0KG8CUZAHlXfAKTF9Ol5PXhiMh39yRL2ChRH1cuuUGOcVyyrhQIw==} engines: {node: ^10.12.0 || >=12.0.0} peerDependencies: @@ -450,7 +458,7 @@ packages: - typescript dev: true - /@typescript-eslint/parser/3.10.1_eslint@7.32.0+typescript@4.5.4: + /@typescript-eslint/parser/3.10.1_ek2rpc4knwwiwkb7dlup4o3xyy: resolution: {integrity: sha512-Ug1RcWcrJP02hmtaXVS3axPPTTPnZjupqhgj+NnZ6BCkwSImWk/283347+x9wN+lqOdK9Eo3vsyiyDHgsmiEJw==} engines: {node: ^10.12.0 || >=12.0.0} peerDependencies: @@ -461,7 +469,7 @@ packages: optional: true dependencies: '@types/eslint-visitor-keys': 1.0.0 - '@typescript-eslint/experimental-utils': 3.10.1_eslint@7.32.0+typescript@4.5.4 + '@typescript-eslint/experimental-utils': 3.10.1_ek2rpc4knwwiwkb7dlup4o3xyy '@typescript-eslint/types': 3.10.1 '@typescript-eslint/typescript-estree': 3.10.1_typescript@4.5.4 eslint: 7.32.0 @@ -636,11 +644,6 @@ packages: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} dev: true - /array-back/3.1.0: - resolution: {integrity: sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==} - engines: {node: '>=6'} - dev: false - /array-find-index/1.0.2: resolution: {integrity: sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=} engines: {node: '>=0.10.0'} @@ -750,7 +753,6 @@ packages: /cac/6.7.12: resolution: {integrity: sha512-rM7E2ygtMkJqD9c7WnFU6fruFcN3xe4FM5yUmgxhZzIKJk4uHl9U/fhwdajGFQbQuv43FAUo1Fe8gX/oIKDeSA==} engines: {node: '>=8'} - dev: true /caching-transform/4.0.0: resolution: {integrity: sha512-kpqOvwXnjjN44D89K5ccQC+RUrsy7jB/XLlRrx0D7/2HNcTPqzsb6XgYoErwko6QsV184CA2YgS1fxDiiDZMWA==} @@ -978,16 +980,6 @@ packages: /color-name/1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - /command-line-args/5.2.0: - resolution: {integrity: sha512-4zqtU1hYsSJzcJBOcNZIbW5Fbk9BkjCp1pZVhQKoRaWL5J7N4XphDLwo8aWwdQpTugxwu+jf9u2ZhkXiqp5Z6A==} - engines: {node: '>=4.0.0'} - dependencies: - array-back: 3.1.0 - find-replace: 3.0.0 - lodash.camelcase: 4.3.0 - typical: 4.0.0 - dev: false - /commander/4.1.1: resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==} engines: {node: '>= 6'} @@ -1863,13 +1855,6 @@ packages: resolution: {integrity: sha512-o4UcykWV/XN9wm+jMEtWLPlV8RXCZnMhQI6F6OdHeSez7iiJWePw8ijOlskJZMsaQoGR/b7dH6lO02HhaTN7+A==} dev: true - /find-replace/3.0.0: - resolution: {integrity: sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==} - engines: {node: '>=4.0.0'} - dependencies: - array-back: 3.1.0 - dev: false - /find-up/1.1.2: resolution: {integrity: sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=} engines: {node: '>=0.10.0'} @@ -2093,6 +2078,8 @@ packages: resolution: {integrity: sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=} engines: {node: '>=4'} dependencies: + '@types/keyv': 3.1.4 + '@types/responselike': 1.0.0 create-error-class: 3.0.2 duplexer3: 0.1.4 get-stream: 3.0.0 @@ -2597,10 +2584,6 @@ packages: p-locate: 5.0.0 dev: true - /lodash.camelcase/4.3.0: - resolution: {integrity: sha1-soqmKIorn8ZRA1x3EfZathkDMaY=} - dev: false - /lodash.flattendeep/4.4.0: resolution: {integrity: sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=} dev: true @@ -3886,11 +3869,6 @@ packages: hasBin: true dev: true - /typical/4.0.0: - resolution: {integrity: sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw==} - engines: {node: '>=8'} - dev: false - /unique-string/1.0.0: resolution: {integrity: sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo=} engines: {node: '>=4'} diff --git a/src/cli/dev.ts b/src/cli/dev.ts deleted file mode 100644 index 71798a3..0000000 --- a/src/cli/dev.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { main } from "."; - -main(process.argv.slice(2)) - .catch(e => { - console.error(e); - process.exit(1); - }); diff --git a/src/cli/parse-args.ts b/src/cli/parse-args.ts index a0f7fc0..1518690 100644 --- a/src/cli/parse-args.ts +++ b/src/cli/parse-args.ts @@ -1,9 +1,10 @@ -import commandLineArgs from "command-line-args"; import { valid as isValidVersion } from "semver"; import { isReleaseType } from "../release-type"; import { VersionBumpOptions } from "../types/version-bump-options"; import { ExitCode } from "./exit-code"; import { usageText } from "./help"; +import cac from 'cac' +import {version} from '../../package.json' /** * The parsed command-line arguments @@ -20,56 +21,44 @@ export interface ParsedArgs { */ export function parseArgs(argv: string[]): ParsedArgs { try { - let args = commandLineArgs( - [ - { name: "preid", type: String }, - { name: "commit", alias: "c", type: String }, - { name: "tag", alias: "t", type: String }, - { name: "push", alias: "p", type: Boolean }, - { name: "all", alias: "a", type: Boolean }, - { name: "no-verify", type: Boolean }, - { name: "quiet", alias: "q", type: Boolean }, - { name: "version", alias: "v", type: Boolean }, - { name: "help", alias: "h", type: Boolean }, - { name: "ignore-scripts", type: Boolean }, - { name: "execute", alias: "x", type: String }, - { name: "files", type: String, multiple: true, defaultOption: true }, - ], - { argv } - ); + +const cli = cac('bumpp') + +cli + .version(version) + .usage('[...files]') + .option('--preid ', 'ID for prerelease') + .option('--all', 'Include all files') + .option('-c, --commit [msg]', 'Commit message', {default: true}) + .option('-t, --tag [tag]', 'Tag name', {default: true}) + .option('-p, --push', 'Push to remote', {default: true}) + .option('--no-verify', 'Skip git verification') + .option('--ignore-scripts', 'Ignore scripts', {default: false}) + .option('-q, --quiet', 'Quiet mode') + .option('-v, --version ', 'Tagert version') + .option('-x, --execute ', 'Commands to execute after version bumps') + .help() + + const args = cli.parse().options + let parsedArgs: ParsedArgs = { help: args.help as boolean, version: args.version as boolean, quiet: args.quiet as boolean, options: { - preid: args.preid as string, - commit: args.commit as string | boolean, - tag: args.tag as string | boolean, - push: args.push as boolean, - all: args.all as boolean, - noVerify: args["no-verify"] as boolean, - files: args.files as string[], - ignoreScripts: args["ignore-scripts"] as boolean, - execute: args.execute as string | undefined, + preid: args.preid, + commit: args.commit, + tag: args.tag, + push: args.push, + all: args.all, + noVerify: !args.verify, + files: args['--'], + ignoreScripts: args.ignoreScripts, + execute: args.execute, } }; - // If --preid is used without an argument, then throw an error, since it's probably a mistake. - // If they want to use the default value ("beta"), then they should not pass the argument at all - if (args.preid === null) { - throw new Error("The --preid option requires a value, such as \"alpha\", \"beta\", etc."); - } - - // If --commit is used without an argument, then treat it as a boolean flag - if (args.commit === null) { - parsedArgs.options.commit = true; - } - - // If --tag is used without an argument, then treat it as a boolean flag - if (args.tag === null) { - parsedArgs.options.tag = true; - } // If a version number or release type was specified, then it will mistakenly be added to the "files" array if (parsedArgs.options.files && parsedArgs.options.files.length > 0) { @@ -81,6 +70,7 @@ export function parseArgs(argv: string[]): ParsedArgs { } } + return parsedArgs; } catch (error) {