Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(cli): port cli to typescript #978

Closed
wants to merge 23 commits into from

Conversation

armano2
Copy link
Contributor

@armano2 armano2 commented Feb 8, 2020

Description

Part of #659

At first i wanted to just migrate it without refactoring, but as meow@v5.0.0 has horrible type and v6 (current) is just a wrapper for yargs (with horrible types) than we can use yargs directly to reduce complexity.

while reviewing i do recommend to disable whitespaces as diff is getting way more readable
https://github.com/conventional-changelog/commitlint/pull/978/files?utf8=✓&diff=split&w=1

Motivation and Context

Ported cli to typescript as part of #659

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@armano2 armano2 force-pushed the refactor-cli branch 2 times, most recently from 6ddc1a1 to 00304bc Compare February 8, 2020 02:55
@@ -114,7 +114,7 @@ export type QualifiedRules = Partial<RulesConfig<RuleConfigQuality.Qualified>>;
export interface QualifiedConfig {
extends: string[];
formatter: unknown;
rules: Partial<QualifiedRules>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QualifiedRules is already Partial

@armano2
Copy link
Contributor Author

armano2 commented Feb 8, 2020

seems that linux build is failing due to:
microsoft/TypeScript#16257

@armano2 armano2 force-pushed the refactor-cli branch 2 times, most recently from f02aacb to 5d6fb5e Compare February 8, 2020 03:39
@armano2
Copy link
Contributor Author

armano2 commented Feb 8, 2020

yargs has built in feature of producing help:

$> commitlint -h
@commitlint/cli@8.3.5 - Lint your commit messages
[input] reads from stdin if --edit, --env, --from and --to are omitted

Options:
  --color, -c          toggle colored output           [boolean] [default: true]
  --config, -g         path to the config file                          [string]
  --cwd, -d            directory to execute in
                                  [string] [default: "mnt:/projects/commitlint"]
  --edit, -e           read last commit message from the specified file or
                       fallbacks to ./.git/COMMIT_EDITMSG
                                                       [string] [default: false]
  --env, -E            check message in the file at path given by environment
                       variable value                                   [string]
  --extends, -x        array of shareable configurations to extend       [array]
  --help-url, -H       helpurl in error message                         [string]
  --from, -f           lower end of the commit range to lint; applies if
                       edit=false                                       [string]
  --format, -o         output format of the results                     [string]
  --parser-preset, -p  configuration preset to use for
                       conventional-commits-parser                      [string]
  --quiet, -q          toggle console output          [boolean] [default: false]
  --to, -t             upper end of the commit range to lint; applies if
                       edit=false                                       [string]
  --verbose, -V        enable verbose output for reports without problems
                                                                       [boolean]
  -v, --version        display version information                     [boolean]
  -h, --help           Show help                                       [boolean]

@commitlint/cli/index.js Outdated Show resolved Hide resolved
@armano2
Copy link
Contributor Author

armano2 commented Feb 8, 2020

for now i'v done simple migration, but we could move most of args validations to yargs
this can/should be should be done in follow up PR, to ease review

@commitlint/cli/src/cli.ts Outdated Show resolved Hide resolved
@commitlint/cli/src/cli.ts Outdated Show resolved Hide resolved
@commitlint/cli/src/cli.ts Outdated Show resolved Hide resolved
@commitlint/cli/src/cli.ts Outdated Show resolved Hide resolved
@marionebl marionebl self-requested a review February 9, 2020 08:45
@armano2
Copy link
Contributor Author

armano2 commented Feb 9, 2020

it seems that you did some mistakes while doing rebase

@commitlint/cli/package.json Show resolved Hide resolved
@commitlint/cli/src/cli.test.ts Show resolved Hide resolved
@commitlint/lint/src/lint.ts Show resolved Hide resolved
@escapedcat
Copy link
Member

@armano2 thanks so much for all your efforts! ❤️

@byCedric
Copy link
Member

Awesome work @armano2! We fixed the conflicts and will merge this one through #1998

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants