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

Feat: predefined scope options #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ThisIsMissEm
Copy link
Owner

@ThisIsMissEm ThisIsMissEm commented Jul 24, 2020

This allows you to configure a predefined number of scopes, and then gives the user a nice graphical way to select one or enter their own. It should be backwards compatible with cz-conventional-changelog, and accept defaults via the same environment variable or config option as the existing scopes functionality.

Screenshot 2020-07-24 at 21 54 15

The package.json configuration:
Screenshot 2020-07-24 at 22 00 54

…rompter

This allows us to use methods from inquirer, such as the Separator class, before actually calling
prompter()
@ThisIsMissEm ThisIsMissEm force-pushed the feat/predefined-scope-options branch from 16a5224 to fd0c825 Compare July 29, 2020 01:48
Previously configuration was tested by mocking our own code, as well as code that we don't own (other modules), this was because configuration took place at require-time of the cz-conventional-commit module, rather than at execution-time. By moving configuration evaluation to execution-time we can better test the logic involved in loading and evaluating configuration.

The removal of the dependency on cosmiconfig comes because we no longer need to mock this module which is a 2nd degree dependency: it's used by commitlint, which we can just mock directly. The previous mocking was needed to override the max-header-length option in a really round-about manner where all tests effectively depended on commitlint, even though that wasn't what the functionality actually was.

This changeset all means that we can test loading and evaluating configuration in isolation, without involving the engine.
Allow users to configure a predefined list of scopes that can be selected from, with the option to
type their own scope if it's not on the list. When passing CZ_SCOPE, we attempt to pre-select the
scope from the list of scopes, or auto-select "something else" which allows the user to confirm the
CZ_SCOPE value.
Previously specifying a custom max header width wasn't actually tested for, only the configuration
loading was tested. This ensures that we have coverage on this functionality.
@ThisIsMissEm ThisIsMissEm force-pushed the feat/predefined-scope-options branch from fd0c825 to 1964940 Compare July 29, 2020 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant