Skip to content

Rename to commitlint #42

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

Merged
merged 217 commits into from
Jul 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
217 commits
Select commit Hold shift + click to select a range
19ebbe2
chore: lerna setup
marionebl Jul 7, 2017
50d5ba4
chore: initial commit
marionebl Feb 14, 2016
e18c3c1
feat: support multiple inputs
marionebl Feb 14, 2016
2338588
feat: add input from git history
marionebl Feb 14, 2016
bc5d267
style: correct typos
marionebl Feb 14, 2016
31fe058
chore: add commitizen
marionebl Feb 14, 2016
5a51694
chore: use conventional-changelog-lint-config-angular
marionebl Feb 14, 2016
da1364c
chore: use husky for git hook linting
marionebl Feb 14, 2016
a137d66
refactor: move utility functions into library, expose them
marionebl Feb 14, 2016
11cba39
fix: be less strict with matched languages
marionebl Feb 14, 2016
717446b
feat: add extends flag
marionebl Feb 14, 2016
c14cec5
docs: add basic documentation
marionebl Feb 14, 2016
025c94b
fix: handle precedence and defaults correctly
marionebl Feb 14, 2016
2b6d205
chore(release): 0.1.0 <a name="0.1.0"></a> # 0.1.0 (2016-02-14)
marionebl Feb 14, 2016
28299f2
fix: rebuild before releases
marionebl Feb 14, 2016
ef8b17c
chore(release): 0.1.1 <a name="0.1.1"></a> ## [0.1.1](https://github.…
marionebl Feb 14, 2016
7280fa4
fix: enforce addition of distribution folder
marionebl Feb 14, 2016
c468682
chore(release): 0.1.2 <a name="0.1.2"></a> ## [0.1.2](https://github.…
marionebl Feb 14, 2016
f58f87c
fix: add missing shebang
marionebl Feb 14, 2016
6a764e4
chore(release): 0.1.3 <a name="0.1.3"></a> ## [0.1.3](https://github.…
marionebl Feb 14, 2016
53f4ce4
fix: correct dependencies
marionebl Feb 14, 2016
9429c5f
chore(release): 0.1.4 <a name="0.1.4"></a> ## [0.1.4](https://github.…
marionebl Feb 14, 2016
79d47b1
fix: add missing dependency
marionebl Feb 14, 2016
fdbef21
chore(release): 0.1.5 <a name="0.1.5"></a> ## [0.1.5](https://github.…
marionebl Feb 14, 2016
2610d42
chore: update conventional-changelog-lint-config-angular
marionebl Feb 14, 2016
90f7f5c
chore(release): 0.1.6 <a name="0.1.6"></a> ## [0.1.6](https://github.…
marionebl Feb 14, 2016
381571f
fix: prune duplicate dependency
marionebl Feb 14, 2016
71268b9
chore(release): 0.1.7 <a name="0.1.7"></a> ## [0.1.7](https://github.…
marionebl Feb 14, 2016
5151656
chore: respect the --[e]dit flag as documented
marionebl Feb 22, 2016
d1716b4
chore(release): 0.1.8 <a name="0.1.8"></a> ## [0.1.8](https://github.…
marionebl Feb 22, 2016
808152e
test: foo
marionebl Feb 22, 2016
90648a6
refactor: expose the entire commit message as raw to rules
marionebl Feb 22, 2016
48485f2
fix: use raw commit message to check for leading blank line
marionebl Feb 22, 2016
1fac0c6
chore(release): 0.1.9 <a name="0.1.9"></a> ## [0.1.9](https://github.…
marionebl Feb 22, 2016
868987d
fix: skip language check if no lang is detected
marionebl Feb 24, 2016
4fdea1b
chore: ensure release commits fulfill [body-leading-blank]
marionebl Feb 24, 2016
ac4cb31
chore(release): 0.1.10
marionebl Feb 24, 2016
3b77bc1
docs: fix code formatting
marionebl Feb 24, 2016
c4d95c9
chore: update devDependencies
marionebl Feb 24, 2016
a813929
feat: support for dynamic and async rules
marionebl Feb 25, 2016
0beecfe
fix: catch unhandled rejections
marionebl Feb 25, 2016
8183f99
chore: update devDependencies
marionebl Feb 25, 2016
e2ad0cd
chore(release): 0.2.0
marionebl Feb 25, 2016
5b84e2c
refactor: move lang detection to library module
marionebl Feb 25, 2016
43633b3
feat: add subject-leading-capital rule
marionebl Feb 25, 2016
1592c45
feat: add footer rules
marionebl Feb 25, 2016
5efd550
feat(rules): add rules for tense-checking
marionebl Feb 25, 2016
363c8aa
chore(release): 0.3.0
marionebl Feb 25, 2016
9544057
fix: guard pos lexer against errors
marionebl Feb 25, 2016
622d2fc
chore(release): 0.3.1
marionebl Feb 25, 2016
4b31b70
docs: add fancy demo gif
marionebl Mar 1, 2016
bd9b797
docs: update readme
marionebl Mar 1, 2016
613fb99
fix: execute dynamic configuration in get-configuration
marionebl Mar 1, 2016
58b7475
chore(release): 0.3.2
marionebl Mar 3, 2016
e4af03a
chore(system): introduce conventional-changelog-lint commitizen adapter
marionebl Mar 7, 2016
f7fa83d
fix(cli): disable angular defaults when a rc file is provided
marionebl Apr 15, 2016
3e842fd
docs(system): add related projects link list
marionebl Apr 15, 2016
c4a78a7
chore(system): resync with github releases
marionebl Apr 15, 2016
e5f8174
chore(system): update release scripts
marionebl Apr 15, 2016
1751fe9
chore(release): v0.3.4 <a name="0.3.4"></a> ## [0.3.4](https://github…
marionebl Apr 15, 2016
a573fbc
chore(system): adapt push scripts
marionebl Apr 15, 2016
848d01a
feat(rules): update to latest default ruleset
marionebl Jun 20, 2016
0e21683
chore(release): v1.0.0 <a name="1.0.0"></a> # [1.0.0](https://github.…
marionebl Jun 20, 2016
b5da3fc
fix(rules): respect keyword setting for scope-empty (#11)
marionebl Aug 15, 2016
e93cdd3
chore(release): v1.0.1 <a name="1.0.1"></a> ## [1.0.1](https://github…
marionebl Aug 15, 2016
91a6c86
chore: update dev tooling
marionebl Nov 1, 2016
fe328c2
feat: update angular config
marionebl Nov 1, 2016
361d557
chore(release): v1.1.0 <a name="1.1.0"></a> # [1.1.0](https://github.…
marionebl Nov 1, 2016
c470798
docs: Fix typo in README
honzajavorek Nov 7, 2016
78169f1
chore: update dependencies
marionebl Mar 3, 2017
b4dfaf4
chore(release): v1.1.1 <a name="1.1.1"></a> ## [1.1.1](https://github…
marionebl Mar 3, 2017
93039cd
docs: specify supported Node.js versions
marionebl Mar 6, 2017
c608488
chore: add CI setup
marionebl Mar 6, 2017
74ef65c
chore: build before npm test
marionebl Mar 6, 2017
2bf4daf
docs: add CI badges
marionebl Mar 6, 2017
ec5d726
chore: tweaks to CI setup
marionebl Mar 6, 2017
b9db9c4
fix: allow empty scopes in scope-enum check
marionebl Mar 10, 2017
7ab6380
chore(release): v1.1.2 <a name="1.1.2"></a> ## [1.1.2](https://github…
marionebl Mar 10, 2017
6a4db78
test: add integration testing for get-messages
marionebl Mar 12, 2017
f30b216
fix: determine git toplevel before reading .git/COMMIT_EDITMSG
marionebl Mar 12, 2017
6a3f499
chore: get rid of babel-preset-es2015-node4 and its deprecation
marionebl Mar 12, 2017
49940ce
chore: ensure presence of regenerator
marionebl Mar 12, 2017
bfa8eb6
chore(release): v1.1.3 <a name="1.1.3"></a> ## [1.1.3](https://github…
marionebl Mar 12, 2017
52da548
fix: move git-toplevel to dependencies
marionebl Mar 12, 2017
a1941ca
chore(release): v1.1.4 <a name="1.1.4"></a> ## [1.1.4](https://github…
marionebl Mar 12, 2017
25a7db6
chore: remove superfluous babel packages
marionebl Mar 12, 2017
e0b52fb
chore(release): v1.1.5 <a name="1.1.5"></a> ## [1.1.5](https://github…
marionebl Mar 12, 2017
05a53d9
fix: add missing globby dependency
marionebl Mar 12, 2017
52195aa
chore(release): v1.1.6 <a name="1.1.6"></a> ## [1.1.6](https://github…
marionebl Mar 12, 2017
8871da1
fix: move mz to dependencies
marionebl Mar 12, 2017
fac420b
chore(release): v1.1.7 <a name="1.1.7"></a> ## [1.1.7](https://github…
marionebl Mar 12, 2017
940f929
refactor: enable static analysis of dependency tree
marionebl Mar 13, 2017
136f3b1
chore: check dependencies via dependency-check
marionebl Mar 13, 2017
d6f918c
chore: build only on oldest supported node on appveyor
marionebl Mar 13, 2017
810260c
chore(package): update conventional-changelog-lint-config-angular
Scrum Mar 31, 2017
a04f948
chore(release): v1.1.8 <a name="1.1.8"></a> ## [1.1.8](https://github…
Mar 31, 2017
c89de69
fix(rules): export subject-min-length rule
whizark Apr 4, 2017
fa56be0
fix: override arrays when merging user configuration
marionebl Mar 31, 2017
dd95b73
chore(release): v1.1.9 <a name="1.1.9"></a> ## [1.1.9](https://github…
marionebl Apr 5, 2017
1b242a7
fix: throw when detecting a shallow clone
marionebl May 1, 2017
d58e421
fix: prevent false positives for footer-leading-blank (#33)
marionebl May 1, 2017
440f81b
chore: test commits in pr via Travis CI (#37)
marionebl May 3, 2017
29484df
chore: solidify lint-prcommits
marionebl May 3, 2017
2d1d538
chore: tweaks to commit linting
marionebl May 3, 2017
71a4401
docs: add recipe for linting of all commits in a PR (#36)
marionebl May 4, 2017
34585dc
fix: rebuff rules (#34)
marionebl Jul 7, 2017
893b792
refactor: move ignore wildcard matching to isIgnore method
marionebl Jul 7, 2017
fc12382
feat: ignore fixup and squash commit (#17)
marionebl Jul 7, 2017
fe53d35
chore(release): v2.0.0 <a name="2.0.0"></a> # [2.0.0](https://github.…
marionebl Jul 7, 2017
6c5806a
fix: update to latest angular config
marionebl Jul 7, 2017
799cfc5
chore(release): v2.1.0 <a name="2.1.0"></a> # [2.1.0](https://github.…
marionebl Jul 7, 2017
60474c8
chore: conventional-changelog-lint => commitlint-cli
marionebl Jul 7, 2017
93e4d49
chore: initial commit
marionebl Feb 14, 2016
68133fb
style: fix indentation
marionebl Feb 14, 2016
1945c3b
feat: assemble basic angular ruleset
marionebl Feb 14, 2016
6e656b0
docs: document ruleset
marionebl Feb 14, 2016
d7fc1db
chore(release): 0.1.0 <a name="0.1.0"></a> # 0.1.0 (2016-02-14)
marionebl Feb 14, 2016
d796a2c
style: remove unneeded disabled rules
marionebl Feb 14, 2016
b671ad7
chore(release): 0.1.1 <a name="0.1.1"></a> ## [0.1.1](https://github.…
marionebl Feb 14, 2016
b2644bc
fix: correct wildcard patterns
marionebl Feb 14, 2016
585a601
chore(release): 0.1.2 <a name="0.1.2"></a> ## [0.1.2](https://github.…
marionebl Feb 14, 2016
43ce2c7
fix: match gitlab auto-merge messages with merge wildcards
marionebl Feb 22, 2016
10b810b
chore: use conventional-changelog-lint
marionebl Feb 22, 2016
6669b18
chore(release): 0.1.3 <a name="0.1.3"></a> ## [0.1.3](https://github.…
marionebl Feb 22, 2016
b1d397a
fix: match multi-digit releases with wildcard
marionebl Feb 24, 2016
a78fef0
chore(release): 0.1.4 <a name="0.1.4"></a> ## [0.1.4](https://github.…
marionebl Feb 24, 2016
b991ea2
style: sort config keys alphabetically
marionebl Feb 25, 2016
c0a6ad1
chore: update devDependencies
marionebl Feb 25, 2016
3b2c80d
feat: add footer-leading-blank rule
marionebl Feb 25, 2016
c8f7fc6
feat: add *-tense rules
marionebl Feb 25, 2016
983a300
chore(release): 0.2.0 <a name="0.2.0"></a> # [0.2.0](https://github.c…
marionebl Feb 25, 2016
2fdaf29
fix: footer-leading-blank should warn
marionebl Feb 25, 2016
0829d52
chore(release): 0.2.1 <a name="0.2.1"></a> ## [0.2.1](https://github.…
marionebl Feb 25, 2016
dee8fdd
chore(release): 0.2.2 <a name="0.2.2"></a> ## [0.2.2](https://github.…
marionebl Feb 25, 2016
847ff41
fix: adhere to angular types
marionebl Mar 7, 2016
6ab3ca6
chore(release): 0.2.3 <a name="0.2.3"></a> ## [0.2.3](https://github.…
marionebl Jun 20, 2016
f99272d
feat: add angular 2x commit types
ellerbrock Nov 1, 2016
3b2361a
chore: update dev dependencies
ellerbrock Nov 1, 2016
e05b5d1
docs: mention angular 2 transition, update type-enum
marionebl Nov 1, 2016
dbdcb86
chore: update dev tooling
marionebl Nov 1, 2016
bdb94db
chore(release): 0.3.0 <a name="0.3.0"></a> # [0.3.0](https://github.c…
marionebl Nov 1, 2016
00efd20
feat: add wildcards for prerelease
Scrum Dec 27, 2016
0f2fa40
chore(release): 0.4.0 <a name="0.4.0"></a> # [0.4.0](https://github.c…
marionebl Mar 3, 2017
0e26aff
fix: match remote tracking branches in ignore pattern
Scrum Mar 23, 2017
3cdc784
chore(release): 0.4.1 <a name="0.4.1"></a> ## [0.4.1](https://github.…
marionebl Mar 23, 2017
fea7bfa
chore: remove wildcards as per v2.0.0
marionebl Jul 7, 2017
ac44533
chore(release): 1.0.0 <a name="1.0.0"></a> # [1.0.0](https://github.c…
marionebl Jul 7, 2017
2cec5ac
chore: conventional-changelog-lint-config-angular => commitlint-confi…
marionebl Jul 7, 2017
4cb9f8e
feat: basic project setup
marionebl Mar 1, 2016
bde4745
chore(release): 0.1.0 <a name="0.1.0"></a> # 0.1.0 (2016-03-03)
marionebl Mar 3, 2016
8d7b0c5
fix(system): publish from distribution
marionebl Mar 3, 2016
1241f2e
chore(release): 0.1.1 <a name="0.1.1"></a> ## [0.1.1](https://github.…
marionebl Mar 3, 2016
ce4110f
fix(system): publish from distribution
marionebl Mar 3, 2016
7538961
chore(release): 0.1.2 <a name="0.1.2"></a> ## [0.1.2](https://github.…
marionebl Mar 3, 2016
1721eed
fix: correct dependency type for babel-polyfill
marionebl Mar 13, 2016
b91b6db
chore(release): 0.1.3 <a name="0.1.3"></a> ## [0.1.3](https://github.…
marionebl Mar 13, 2016
b4ce44e
feat: extend config-angular with rule for scope-enum
marionebl Feb 25, 2016
aa25c4b
chore(release): 0.1.0 <a name="0.1.0"></a> # 0.1.0 (2016-02-25)
marionebl Feb 25, 2016
2c09e4f
feat: update to latest config-angular
marionebl Feb 25, 2016
0f413cb
chore(release): 0.2.0 <a name="0.2.0"></a> # [0.2.0](https://github.c…
marionebl Feb 25, 2016
b0d6dc8
chore: initial commit
marionebl Mar 12, 2017
ec999c3
refactor: rename all packages
marionebl Jul 7, 2017
56f5dfa
fix: add missing devDependency
marionebl Jul 7, 2017
a84fcba
refactor: scope all packages
marionebl Jul 8, 2017
ff8fbd7
refactor(cli): remove config-angular from default installs
marionebl Jul 8, 2017
95a9dc4
test(core): add test case for relative extend items
marionebl Jul 8, 2017
dfb661f
feat(core): do not prefix relative extends
marionebl Jul 8, 2017
42e308e
test(core): mark regression as failing
marionebl Jul 8, 2017
2257a80
fix(core): resolve extends relative to config file
marionebl Jul 8, 2017
e715d86
fix: enable recursive relative extends
marionebl Jul 8, 2017
15c0f68
refactor: simplify api considerably
marionebl Jul 9, 2017
741b633
test(core): add structural test
marionebl Jul 9, 2017
b55693c
test(core): add superficial tests for lint()
marionebl Jul 9, 2017
78db7df
docs: rework root readme
marionebl Jul 9, 2017
1ab1ee8
docs: refine shareable-config docs
marionebl Jul 9, 2017
e55f711
refactor(cli): remove obsolete preset flag
marionebl Jul 9, 2017
646b0a0
docs: move doc bodies to docs/
marionebl Jul 9, 2017
153c742
docs: unify config docs
marionebl Jul 9, 2017
90b7288
docs: add upgrade guide
marionebl Jul 9, 2017
b7396f5
test(cli): add basic cli integration tests
marionebl Jul 9, 2017
a2798d3
chore: unify dep-checks and linting
marionebl Jul 9, 2017
7b96af5
docs: => commitlint
marionebl Jul 9, 2017
2d11e9f
docs: remove footer
marionebl Jul 9, 2017
bc460c8
fix(utils): better cross-version support
marionebl Jul 9, 2017
030298e
feat(core): readd support for .conventional-changelog-lintrc
marionebl Jul 9, 2017
94437e8
fix(cli): remove destructuring for node 4 support
marionebl Jul 9, 2017
a5e658a
fix: ensure node4 compat
marionebl Jul 9, 2017
3092ce5
feat(core): support conventional-changelog-lint-config-*
marionebl Jul 9, 2017
089a7ad
refactor(prompt): reorganize sources
marionebl Jul 10, 2017
903df4b
feat(config-lerna-scopes): support non-standard lerna repos
marionebl Jul 10, 2017
80501e8
docs(prompt): rephrase docs
marionebl Jul 10, 2017
b0239d2
feat(prompt-cli): add standalone prompt interface
marionebl Jul 10, 2017
ca4adf9
docs: mention prompt-cli
marionebl Jul 10, 2017
9a3f281
chore: eat your own dogfood
marionebl Jul 10, 2017
654ace5
docs: => commitlint
marionebl Jul 10, 2017
2c9df0b
chore: use commitmsg hook
marionebl Jul 10, 2017
288721e
chore(core): unlock dependencies
marionebl Jul 10, 2017
f7f0c0b
chore(config-lerna-scopes): sanitize dependencies
marionebl Jul 10, 2017
ba414c5
docs(config-patternplate): sanitize description
marionebl Jul 10, 2017
bfd6e7e
chore(prompt): unlock dependencies
marionebl Jul 10, 2017
9047322
chore: add trevor setup
marionebl Jul 10, 2017
8c0364e
test(cli): harden harness against side effects
marionebl Jul 10, 2017
1da724c
test(core): mark test as failing ftb
marionebl Jul 10, 2017
9e25cc6
chore: enable vscode xo linting
marionebl Jul 10, 2017
e5b718f
refactor(core): read config from commitlint.config.js
marionebl Jul 10, 2017
22c2f46
chore: test on node 8
marionebl Jul 10, 2017
1058025
style(prompt): remove dead code
marionebl Jul 10, 2017
aa9ad03
docs: add guides
marionebl Jul 10, 2017
67ba5c6
feat: alias config packages
marionebl Jul 10, 2017
ead20b6
fix(core): ignore version commits with leading whitespace
marionebl Jul 10, 2017
68a4d9a
docs: rename changelog
marionebl Jul 10, 2017
455b092
v3.0.0
marionebl Jul 10, 2017
6dc909e
chore: remove dep-test from config mirrors
marionebl Jul 10, 2017
2bcc941
fix: use conventional-changelog-angular again
marionebl Jul 11, 2017
5a41f16
v3.0.1
marionebl Jul 11, 2017
ade30ad
chore: add publish script
marionebl Jul 11, 2017
8eee1d1
chore: avoid win32 related npm@5 bugs
marionebl Jul 11, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 5 additions & 37 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,41 +1,9 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
lerna-debug.log
node_modules

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# jsonlint-cli cache
.tmp

# transpiled artifacts
distribution

.nyc_output
.dockerignore
.*.dockerfile
@commitlint/**/lib
@commitlint/**/package.json.lerna_backup
9 changes: 1 addition & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
language: node_js
node_js:
- '7'
- '8'
- '6'
- '4'
before_install:
- git fetch --unshallow
before_script:
- npm run build
script:
- npm run travis:lint:commits
- npm test
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Place your settings in this file to overwrite default and user settings.
{
"xo.enable": true
}
30 changes: 30 additions & 0 deletions @commitlint/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Change Log

All notable changes to this project will be documented in this file.
See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="3.0.1"></a>
## 3.0.1 (2017-07-11)



<a name="3.0.0"></a>
# 3.0.0 (2017-07-10)


### Bug Fixes

* **cli:** remove destructuring for node 4 support ([94437e8](https://github.com/marionebl/commitlint/commit/94437e8))
* ensure node4 compat ([a5e658a](https://github.com/marionebl/commitlint/commit/a5e658a))




<a name="3.0.0"></a>
# 3.0.0 (2017-07-10)


### Bug Fixes

* **cli:** remove destructuring for node 4 support ([94437e8](https://github.com/marionebl/commitlint/commit/94437e8))
* ensure node4 compat ([a5e658a](https://github.com/marionebl/commitlint/commit/a5e658a))
118 changes: 118 additions & 0 deletions @commitlint/cli/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/usr/bin/env node
require('babel-polyfill'); // eslint-disable-line import/no-unassigned-import

// npm modules
const core = require('@commitlint/core');
const chalk = require('chalk');
const meow = require('meow');
const pick = require('lodash').pick;
const stdin = require('get-stdin');

const pkg = require('./package');
const help = require('./help');

/**
* Behavioural rules
*/
const rules = {
fromStdin: (input, flags) => input.length === 0 &&
typeof flags.from !== 'string' &&
typeof flags.to !== 'string' &&
!flags.edit
};

const configuration = {
string: ['from', 'to', 'extends'],
boolean: ['edit', 'help', 'version', 'quiet', 'color'],
alias: {
c: 'color',
e: 'edit',
f: 'from',
t: 'to',
q: 'quiet',
h: 'help',
v: 'version',
x: 'extends'
},
description: {
color: 'toggle colored output',
edit: 'read last commit message found in ./git/COMMIT_EDITMSG',
extends: 'array of shareable configurations to extend',
from: 'lower end of the commit range to lint; applies if edit=false',
to: 'upper end of the commit range to lint; applies if edit=false',
quiet: 'toggle console output'
},
default: {
color: true,
edit: false,
from: null,
to: null,
quiet: false
},
unknown(arg) {
throw new Error(`unknown flags: ${arg}`);
}
};

const cli = meow({
help: `[input] reads from stdin if --edit, --from and --to are omitted\n${help(configuration)}`,
description: `${pkg.name}@${pkg.version} - ${pkg.description}`
}, configuration);

const load = seed => core.load(seed);

function main(options) {
const raw = options.input;
const flags = options.flags;
const fromStdin = rules.fromStdin(raw, flags);

const range = pick(flags, 'edit', 'from', 'to');
const input = fromStdin ? stdin() : core.read(range);
const fmt = new chalk.constructor({enabled: flags.color});

return input
.then(raw => Array.isArray(raw) ? raw : [raw])
.then(messages => Promise.all(messages.map(commit => {
return load(getSeed(flags))
.then(opts => core.lint(commit, opts.rules))
.then(report => {
const formatted = core.format(report, {color: flags.color});

if (!flags.quiet) {
console.log(`${fmt.grey('⧗')} input: ${fmt.bold(commit.split('\n')[0])}`);
console.log(formatted.join('\n'));
}

if (report.errors.length > 0) {
const error = new Error(formatted[formatted.length - 1]);
error.type = pkg.name;
throw error;
}
return console.log('');
});
})
));
}

function getSeed(seed) {
const e = Array.isArray(seed.extends) ? seed.extends : [seed.extends];
const n = e.filter(i => typeof i === 'string');
return n.length > 0 ? {extends: n} : {};
}

// Start the engine
main(cli)
.catch(err =>
setTimeout(() => {
if (err.type === pkg.name) {
process.exit(1);
}
throw err;
})
);

// Catch unhandled rejections globally
process.on('unhandledRejection', (reason, promise) => {
console.log('Unhandled Rejection at: Promise ', promise, ' reason: ', reason);
throw reason;
});
71 changes: 71 additions & 0 deletions @commitlint/cli/cli.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import path from 'path';
import test from 'ava';
import execa from 'execa';
import stream from 'string-to-stream';

const here = path.join.bind(null, __dirname);

const SIMPLE = here('fixtures/simple');
const EXTENDS_ROOT = here('fixtures/extends-root');
const EMPTY = here('fixtures/empty');

const cli = (input = '', args = [], opts = {}) => {
const c = execa(here('cli.js'), args, {
capture: ['stdout'],
cwd: opts.cwd
});
stream(input).pipe(c.stdin);
return c;
};

test('should throw when called without [input]', t => {
t.throws(cli(), /Expected a raw commit/);
});

test('should reprint input from stdin', async t => {
const actual = await cli('foo: bar', [], {cwd: EMPTY});
t.true(actual.stdout.includes('foo: bar'));
});

test('should produce no success output with --quiet flag', async t => {
const actual = await cli('foo: bar', ['--quiet'], {cwd: EMPTY});
t.is(actual.stdout, '');
t.is(actual.stderr, '');
});

test('should produce no success output with -q flag', async t => {
const actual = await cli('foo: bar', ['-q'], {cwd: EMPTY});
t.is(actual.stdout, '');
t.is(actual.stderr, '');
});

test('should succeed for input from stdin without rules', async t => {
const actual = await cli('foo: bar', [], {cwd: EMPTY});
t.is(actual.code, 0);
});

test('should fail for input from stdin with rule from rc', async t => {
const actual = await t.throws(cli('foo: bar', [], {cwd: SIMPLE}));
t.true(actual.stdout.includes('scope must not be one of [foo]'));
t.is(actual.code, 1);
});

test('should fail for input from stdin with rule from js', async t => {
const actual = await t.throws(cli('foo: bar', ['--extends', './extended'], {cwd: EXTENDS_ROOT}));
t.true(actual.stdout.includes('scope must not be one of [foo]'));
t.is(actual.code, 1);
});

test('should produce no error output with --quiet flag', async t => {
const actual = await t.throws(cli('foo: bar', ['--quiet'], {cwd: SIMPLE}));
t.is(actual.stdout, '');
t.is(actual.stderr, '');
t.is(actual.code, 1);
});

test('should produce no error output with -q flag', async t => {
const actual = await t.throws(cli('foo: bar', ['-q'], {cwd: SIMPLE}));
t.is(actual.stdout, '');
t.is(actual.stderr, '');
t.is(actual.code, 1);
});
1 change: 1 addition & 0 deletions @commitlint/cli/fixtures/empty/commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
5 changes: 5 additions & 0 deletions @commitlint/cli/fixtures/extends-root/extended.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
rules: {
'type-enum': [2, 'never', ['foo']]
}
};
5 changes: 5 additions & 0 deletions @commitlint/cli/fixtures/simple/commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
rules: {
'type-enum': [2, 'never', ['foo']]
}
};
11 changes: 7 additions & 4 deletions source/help.js → @commitlint/cli/help.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export default configuration => {
module.exports = configuration => {
const lines = Object.entries(configuration.description)
.map(entry => {
const [name, desc] = entry;
const name = entry[0];
const desc = entry[1];
const alias = Object.entries(configuration.alias)
.find(entry => entry[1] === name)
.map(entry => entry[0])[0];
Expand All @@ -11,14 +12,16 @@ export default configuration => {

const longest = lines
.map(line => {
const [flags] = line;
const flags = line[0];
return flags.reduce((sum, flag) => sum + flag.length, 0);
})
.sort(Number)[0];

return lines
.map(line => {
const [flags, desc, defaults] = line;
const flags = line[0];
const desc = line[1];
const defaults = line[2];
const fs = flags.map(flag => flag.length > 1 ? `--${flag}` : `-${flag}`);
const ds = defaults ? `, defaults to: ${defaults}` : '';
const length = flags.reduce((sum, flag) => sum + flag.length, 0);
Expand Down
58 changes: 58 additions & 0 deletions @commitlint/cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "@commitlint/cli",
"version": "3.0.1",
"description": "Lint your commit messages",
"bin": {
"commitlint": "cli.js"
},
"scripts": {
"build": "exit 0",
"clean": "exit 0",
"pretest": "dep-check",
"test": "ava",
"prepublish": "npm test"
},
"ava": {
"files": [
"cli.test.js"
]
},
"xo": false,
"engines": {
"node": ">=4"
},
"repository": {
"type": "git",
"url": "https://github.com/marionebl/commitlint.git"
},
"bugs": {
"url": "https://github.com/marionebl/commitlint/issues"
},
"homepage": "https://github.com/marionebl/commitlint#readme",
"keywords": [
"conventional-changelog",
"commitlint",
"cli"
],
"author": {
"name": "Mario Nebl",
"email": "[email protected]"
},
"license": "MIT",
"devDependencies": {
"@commitlint/utils": "^3.0.0",
"ava": "^0.18.2",
"dependency-check": "^2.9.1",
"execa": "^0.7.0",
"string-to-stream": "^1.1.0",
"xo": "^0.18.2"
},
"dependencies": {
"@commitlint/core": "^3.0.1",
"babel-polyfill": "^6.23.0",
"chalk": "^2.0.1",
"get-stdin": "^5.0.1",
"lodash": "^4.17.4",
"meow": "^3.7.0"
}
}
Loading