|
1 | 1 | "format cjs";
|
2 | 2 |
|
3 |
| -var wrap = require('word-wrap'); |
| 3 | +var engine = require('./engine'); |
| 4 | +var conventionalCommitTypes = require('conventional-commit-types'); |
4 | 5 |
|
5 |
| -// This can be any kind of SystemJS compatible module. |
6 |
| -// We use Commonjs here, but ES6 or AMD would do just |
7 |
| -// fine. |
8 |
| -module.exports = { |
9 |
| - |
10 |
| - // When a user runs `git cz`, prompter will |
11 |
| - // be executed. We pass you cz, which currently |
12 |
| - // is just an instance of inquirer.js. Using |
13 |
| - // this you can ask questions and get answers. |
14 |
| - // |
15 |
| - // The commit callback should be executed when |
16 |
| - // you're ready to send back a commit template |
17 |
| - // to git. |
18 |
| - // |
19 |
| - // By default, we'll de-indent your commit |
20 |
| - // template and will keep empty lines. |
21 |
| - prompter: function(cz, commit) { |
22 |
| - console.log('\nLine 1 will be cropped at 100 characters. All other lines will be wrapped after 100 characters.\n'); |
23 |
| - |
24 |
| - // Let's ask some questions of the user |
25 |
| - // so that we can populate our commit |
26 |
| - // template. |
27 |
| - // |
28 |
| - // See inquirer.js docs for specifics. |
29 |
| - // You can also opt to use another input |
30 |
| - // collection library if you prefer. |
31 |
| - cz.prompt([ |
32 |
| - { |
33 |
| - type: 'list', |
34 |
| - name: 'type', |
35 |
| - message: 'Select the type of change that you\'re committing:', |
36 |
| - choices: [ |
37 |
| - { |
38 |
| - name: 'feat: A new feature', |
39 |
| - value: 'feat' |
40 |
| - }, { |
41 |
| - name: 'fix: A bug fix', |
42 |
| - value: 'fix' |
43 |
| - }, { |
44 |
| - name: 'docs: Documentation only changes', |
45 |
| - value: 'docs' |
46 |
| - }, { |
47 |
| - name: 'style: Changes that do not affect the meaning of the code\n (white-space, formatting, missing semi-colons, etc.)', |
48 |
| - value: 'style' |
49 |
| - }, { |
50 |
| - name: 'refactor: A code change that neither fixes a bug or adds a feature', |
51 |
| - value: 'refactor' |
52 |
| - }, { |
53 |
| - name: 'perf: A code change that improves performance', |
54 |
| - value: 'perf' |
55 |
| - }, { |
56 |
| - name: 'test: Adding missing tests', |
57 |
| - value: 'test' |
58 |
| - }, { |
59 |
| - name: 'chore: Changes to the build process or auxiliary tools\n and libraries such as documentation generation', |
60 |
| - value: 'chore' |
61 |
| - }] |
62 |
| - }, { |
63 |
| - type: 'input', |
64 |
| - name: 'scope', |
65 |
| - message: 'Denote the scope of this change ($location, $browser, $compile, etc.):\n' |
66 |
| - }, { |
67 |
| - type: 'input', |
68 |
| - name: 'subject', |
69 |
| - message: 'Write a short, imperative tense description of the change:\n' |
70 |
| - }, { |
71 |
| - type: 'input', |
72 |
| - name: 'body', |
73 |
| - message: 'Provide a longer description of the change:\n' |
74 |
| - }, { |
75 |
| - type: 'input', |
76 |
| - name: 'footer', |
77 |
| - message: 'List any breaking changes or issues closed by this change:\n' |
78 |
| - } |
79 |
| - ]).then(function(answers) { |
80 |
| - |
81 |
| - var maxLineWidth = 100; |
82 |
| - |
83 |
| - var wrapOptions = { |
84 |
| - trim: true, |
85 |
| - newline: '\n', |
86 |
| - indent:'', |
87 |
| - width: maxLineWidth |
88 |
| - }; |
89 |
| - |
90 |
| - // parentheses are only needed when a scope is present |
91 |
| - var scope = answers.scope.trim(); |
92 |
| - scope = scope ? '(' + answers.scope.trim() + ')' : ''; |
93 |
| - |
94 |
| - // Hard limit this line |
95 |
| - var head = (answers.type + scope + ': ' + answers.subject.trim()).slice(0, maxLineWidth); |
96 |
| - |
97 |
| - // Wrap these lines at 100 characters |
98 |
| - var body = wrap(answers.body, wrapOptions); |
99 |
| - var footer = wrap(answers.footer, wrapOptions); |
100 |
| - |
101 |
| - commit(head + '\n\n' + body + '\n\n' + footer); |
102 |
| - }); |
103 |
| - } |
104 |
| -} |
| 6 | +module.exports = engine({ |
| 7 | + types: conventionalCommitTypes.types |
| 8 | +}); |
0 commit comments