This repository has been archived by the owner on Jun 16, 2021. It is now read-only.
forked from streamich/git-cz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,809 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ yarn-error.log | |
dist/ | ||
package-lock.json | ||
/binaries/ | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"arrowParens": "always", | ||
"bracketSpacing": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"extends": "mailonline/mocha" | ||
} | ||
"extends": "mailonline/jest" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`git-cz --help 1`] = ` | ||
" | ||
Semantic emojified git commit, git-cz | ||
Usage: git-cz [options] | ||
options: | ||
-h, --help show usage information | ||
-v, --version print version info and exit | ||
--non-interactive run git-cz in non-interactive mode | ||
non-interactive mode options: | ||
--type type of the commit, defaults to \\"chore\\" | ||
--subject message of the commit, defaults to \\"automated commit\\" | ||
--scope semantic commit scope | ||
--body extended description of the commit | ||
--breaking description of breaking changes, if any | ||
--issues GitHub issues this commit closed, e.g \\"#123\\" | ||
--lerna Lerna mono-repo packages this commit affects | ||
" | ||
`; | ||
|
||
exports[`git-cz --non-interactive 1`] = ` | ||
"Running in dry mode. | ||
Will execute command: | ||
git commit --message 'chore: 🤖 automated commit' | ||
" | ||
`; | ||
|
||
exports[`git-cz 1`] = ` | ||
"Running in dry mode. | ||
[32m?[39m [1mSelect the type of change that you're committing:[22m[0m [0m[2m(Use arrow keys or type to s | ||
earch)[22m | ||
[36m❯ 💍 test: Adding missing tests[39m | ||
🎸 feat: A new feature | ||
🐛 fix: A bug fix | ||
🤖 chore: Build process or auxiliary tool changes | ||
✏️ docs: Documentation only changes | ||
💡 refactor: A code change that neither fixes a bug or adds a feature | ||
💄 style: Markup, white-space, formatting, missing semi-colons... | ||
[2m(Move up and down to reveal more choices)[22m[9A[41D[86C[9B[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G[32m?[39m [1mSelect the type of change that you're committing:[22m[0m [0m | ||
💍 test: Adding missing tests | ||
[36m❯ 🎸 feat: A new feature[39m | ||
🐛 fix: A bug fix | ||
🤖 chore: Build process or auxiliary tool changes | ||
✏️ docs: Documentation only changes | ||
💡 refactor: A code change that neither fixes a bug or adds a feature | ||
💄 style: Markup, white-space, formatting, missing semi-colons... | ||
[2m(Move up and down to reveal more choices)[22m[8A[41D[52C[8B[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G[32m?[39m [1mSelect the type of change that you're committing:[22m[0m [0m[36m🎸 feat: A new featur | ||
e[39m[1A[1D[81C | ||
[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m55 chars left[39m | ||
feat: [9D[9C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m54 chars left[39m | ||
feat: a[10D[10C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m53 chars left[39m | ||
feat: ad[11D[11C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m52 chars left[39m | ||
feat: add[12D[12C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m51 chars left[39m | ||
feat: addi[13D[13C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m50 chars left[39m | ||
feat: addin[14D[14C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m49 chars left[39m | ||
feat: adding[15D[15C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m48 chars left[39m | ||
feat: adding [16D[16C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m47 chars left[39m | ||
feat: adding a[17D[17C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m46 chars left[39m | ||
feat: adding an[18D[18C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m45 chars left[39m | ||
feat: adding an [19D[19C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m44 chars left[39m | ||
feat: adding an a[20D[20C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m43 chars left[39m | ||
feat: adding an aw[21D[21C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m42 chars left[39m | ||
feat: adding an awe[22D[22C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m41 chars left[39m | ||
feat: adding an awes[23D[23C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m40 chars left[39m | ||
feat: adding an aweso[24D[24C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m39 chars left[39m | ||
feat: adding an awesom[25D[25C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m38 chars left[39m | ||
feat: adding an awesome[26D[26C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m37 chars left[39m | ||
feat: adding an awesome [27D[27C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m36 chars left[39m | ||
feat: adding an awesome f[28D[28C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m35 chars left[39m | ||
feat: adding an awesome fe[29D[29C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m34 chars left[39m | ||
feat: adding an awesome fea[30D[30C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m33 chars left[39m | ||
feat: adding an awesome feat[31D[31C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m32 chars left[39m | ||
feat: adding an awesome featu[32D[32C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m31 chars left[39m | ||
feat: adding an awesome featur[33D[33C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m30 chars left[39m | ||
feat: adding an awesome feature[34D[34C[2K[1A[2K[1A[2K[G[32m?[39m [1mWrite a short, imperative mood description of the change:[22m[0m [0m | ||
[-------------------------------------------------------------] [32m55 chars left[39m | ||
feat: adding an awesome feature[34D[34C | ||
[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0m[2D[2C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mt[3D[3C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mth[4D[4C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe[5D[5C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe [6D[6C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe f[7D[7C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe fe[8D[8C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe fea[9D[9C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe feat[10D[10C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe featu[11D[11C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe featur[12D[12C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe feature[13D[13C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe feature [14D[14C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe feature d[15D[15C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe feature de[16D[16C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe feature des[17D[17C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe feature desc[18D[18C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe feature descr[19D[19C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe feature descri[20D[20C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe feature descrip[21D[21C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe feature descript[22D[22C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe feature descripti[23D[23C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe feature descriptio[24D[24C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0mthe feature description[25D[25C[2K[1A[2K[G[32m?[39m [1mProvide a longer description of the change:[22m | ||
[1m [22m[0m [0m[36mthe feature description[39m[25D[25C | ||
[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0m[19D[19C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mS[20D[20C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSo[21D[21C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSom[22D[22C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome[23D[23C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome [24D[24C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome B[25D[25C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome Br[26D[26C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome Bre[27D[27C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome Brea[28D[28C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome Break[29D[29C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome Breaki[30D[30C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome Breakin[31D[31C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome Breaking[32D[32C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome Breaking [33D[33C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome Breaking C[34D[34C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome Breaking Ch[35D[35C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome Breaking Cha[36D[36C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome Breaking Chan[37D[37C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome Breaking Chang[38D[38C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome Breaking Change[39D[39C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0mSome Breaking Changes[40D[40C[2K[1A[2K[G[32m?[39m [1mList any breaking changes[22m | ||
[1m [31mBREAKING CHANGE[39m:[22m[0m [0m[36mSome Breaking Changes[39m[40D[40C | ||
[32m?[39m [1mIssues this commit closes, e.g #123:[22m[0m [0m[39D[39C[2K[G[32m?[39m [1mIssues this commit closes, e.g #123:[22m[0m [0m#[40D[40C[2K[G[32m?[39m [1mIssues this commit closes, e.g #123:[22m[0m [0m#1[41D[41C[2K[G[32m?[39m [1mIssues this commit closes, e.g #123:[22m[0m [0m[36m#1[39m[41D[41C | ||
Will execute command: | ||
git commit --message 'feat: 🎸 adding an awesome feature | ||
the feature description | ||
BREAKING CHANGE: 🧨 Some Breaking Changes | ||
✅ Closes: #1' | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const pkg = require('../package.json'); | ||
const {runCLI, keys} = require('./testUtils'); | ||
|
||
test('git-cz --help', async () => { | ||
const {getResult} = runCLI(['--help']); | ||
|
||
const result = await getResult(); | ||
|
||
expect(result).toMatchSnapshot(); | ||
}); | ||
|
||
test('git-cz --version', async () => { | ||
const {getResult} = runCLI(['--version']); | ||
|
||
const result = await getResult(); | ||
|
||
expect(result.trim()).toBe(pkg.version); | ||
}); | ||
|
||
test('git-cz --non-interactive', async () => { | ||
const {getResult} = runCLI(['--non-interactive', '--dry-run']); | ||
|
||
const result = await getResult(); | ||
|
||
expect(result).toMatchSnapshot(); | ||
}); | ||
|
||
test('git-cz', async () => { | ||
const {getResult, write} = runCLI(['--dry-run']); | ||
|
||
await write([ | ||
keys.down, | ||
keys.enter, | ||
'adding an awesome feature', | ||
keys.enter, | ||
'the feature description', | ||
keys.enter, | ||
'Some Breaking Changes', | ||
keys.enter, | ||
'#1' | ||
]); | ||
|
||
const result = await getResult(); | ||
|
||
expect(result).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const path = require('path'); | ||
const spawn = require('spawncommand'); | ||
|
||
exports.keys = { | ||
down: '\u001B\u005B\u0042', | ||
enter: '\r', | ||
up: '\u001B\u005B\u0041' | ||
}; | ||
|
||
exports.runCLI = (args = []) => { | ||
const CLI_PATH = path.join(__dirname, '/../lib/cli'); | ||
|
||
const {promise, stdin} = spawn('node', [ | ||
CLI_PATH, | ||
...args | ||
]); | ||
|
||
const getResult = async () => { | ||
const {stdout} = await promise; | ||
|
||
return stdout; | ||
}; | ||
|
||
const delay = () => new Promise((resolve) => setTimeout(resolve, 500)); | ||
|
||
const write = async (inputs = []) => { | ||
for (const input of inputs) { | ||
stdin.write(input); | ||
await delay(); | ||
} | ||
|
||
stdin.end(); | ||
}; | ||
|
||
return { | ||
getResult, | ||
write | ||
}; | ||
}; |
Oops, something went wrong.