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
21 changed files
with
211 additions
and
119 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 |
---|---|---|
@@ -1,8 +1,16 @@ | ||
const {prompter} = require('.'); | ||
const signale = require('signale'); | ||
const createState = require('./createState'); | ||
const runInteractiveQuestions = require('./runInteractiveQuestions'); | ||
|
||
const cz = {}; | ||
const onCommit = (data) => { | ||
console.log('receibed for commit', data); | ||
const main = async () => { | ||
try { | ||
const state = createState(); | ||
const answers = await runInteractiveQuestions(state); | ||
|
||
console.log(answers); | ||
} catch (error) { | ||
signale.fatal(error); | ||
} | ||
}; | ||
|
||
prompter(cz, onCommit); | ||
main(); |
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,9 @@ | ||
/* eslint-disable import/no-dynamic-require, global-require */ | ||
|
||
const createQuestions = (state) => { | ||
const questions = state.config.questions.map((name) => require('./questions/' + name).createQuestion(state)); | ||
|
||
return questions.filter(Boolean); | ||
}; | ||
|
||
module.exports = createQuestions; |
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,13 @@ | ||
const appRoot = require('app-root-path'); | ||
const getConfig = require('./getConfig'); | ||
|
||
const createState = () => { | ||
const state = { | ||
config: getConfig(), | ||
root: String(appRoot) | ||
}; | ||
|
||
return state; | ||
}; | ||
|
||
module.exports = createState; |
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
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 was deleted.
Oops, something went wrong.
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,9 @@ | ||
exports.createQuestion = () => { | ||
const question = { | ||
message: 'Provide a longer description of the change:\n ', | ||
name: 'body', | ||
type: 'input' | ||
}; | ||
|
||
return question; | ||
}; |
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,11 @@ | ||
const chalk = require('chalk'); | ||
|
||
exports.createQuestion = () => { | ||
const question = { | ||
message: `List any breaking changes:\n ${chalk.red('BREAKING CHANGE')}:`, | ||
name: 'breaking', | ||
type: 'input' | ||
}; | ||
|
||
return question; | ||
}; |
File renamed without changes.
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,11 @@ | ||
exports.createQuestion = (state) => { | ||
const question = { | ||
choices: allPackages, | ||
default: changedPackages, | ||
message: `The packages that this commit has affected (${changedPackages.length} detected)\n`, | ||
name: 'packages', | ||
type: 'checkbox' | ||
}; | ||
|
||
return question; | ||
}; |
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,25 @@ | ||
exports.createQuestion = (state) => { | ||
const {scopes} = state.config; | ||
|
||
if (!scopes) { | ||
return null; | ||
} | ||
|
||
if (!Array.isArray(scopes)) { | ||
throw new TypeError('scopes must be an array of strings.'); | ||
} | ||
|
||
if (scopes.length < 1) { | ||
return null; | ||
} | ||
|
||
const question = { | ||
choices: scopes, | ||
default: 0, | ||
message: 'Select the scope this component affects:\n', | ||
name: 'scope', | ||
type: 'list' | ||
}; | ||
|
||
return question; | ||
}; |
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,26 @@ | ||
exports.createQuestion = (state) => { | ||
const {config} = state; | ||
const minTitleLengthErrorMessage = `The subject must have at least ${config.minMessageLength} characters`; | ||
const question = { | ||
filter: (input) => { | ||
let subject; | ||
|
||
subject = input.trim(); | ||
while (subject.endsWith('.')) { | ||
subject = subject.substr(0, subject.length - 1).trim(); | ||
} | ||
|
||
return subject; | ||
}, | ||
leadingLabel: (answers) => `${answers.type}:`, | ||
|
||
// Minus 3 chars are for emoji + space. | ||
maxLength: config.maxMessageLength - 3, | ||
message: 'Write a short, imperative mood description of the change:', | ||
name: 'subject', | ||
type: 'limitedInput', | ||
validate: (input) => input.length >= config.minMessageLength || minTitleLengthErrorMessage | ||
}; | ||
|
||
return question; | ||
}; |
Oops, something went wrong.