@4s1/conventional-commit-creator 0.10.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/dist/index.js +9 -58
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
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.
|
|
4
4
|
|
|
5
|
+
## [0.11.0](https://gitlab.com/4s1/conventional-commit-creator/compare/v0.10.2...v0.11.0) (2021-12-26)
|
|
6
|
+
|
|
5
7
|
## [0.10.2](https://gitlab.com/4s1/conventional-commit-creator/compare/v0.9.0...v0.10.2) (2021-12-21)
|
|
6
8
|
|
|
7
9
|
|
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
"use strict";
|
|
3
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
4
|
};
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
6
|
const prompts_1 = __importDefault(require("prompts"));
|
|
8
|
-
const
|
|
7
|
+
const git_1 = require("./git");
|
|
9
8
|
const questions = [
|
|
10
9
|
{
|
|
11
10
|
type: 'select',
|
|
@@ -64,11 +63,12 @@ const questions = [
|
|
|
64
63
|
},
|
|
65
64
|
];
|
|
66
65
|
async function main() {
|
|
67
|
-
|
|
66
|
+
const git = new git_1.Git();
|
|
67
|
+
if (!(await git.isCurrentDirUnderGitControl())) {
|
|
68
68
|
console.error('Current directory is not a git repository.');
|
|
69
69
|
process.exit(0);
|
|
70
70
|
}
|
|
71
|
-
if (!(await haveStagedChanges())) {
|
|
71
|
+
if (!(await git.haveStagedChanges())) {
|
|
72
72
|
console.error('Nothing to commit');
|
|
73
73
|
process.exit(0);
|
|
74
74
|
}
|
|
@@ -78,11 +78,12 @@ async function main() {
|
|
|
78
78
|
process.exit(1);
|
|
79
79
|
},
|
|
80
80
|
}));
|
|
81
|
-
const
|
|
82
|
-
await
|
|
81
|
+
const isAtWork = await git.isAtWork();
|
|
82
|
+
const msg = await createMsg(data, isAtWork);
|
|
83
|
+
await git.commit(msg);
|
|
83
84
|
console.info('done');
|
|
84
85
|
}
|
|
85
|
-
async function createMsg(data) {
|
|
86
|
+
async function createMsg(data, isWork) {
|
|
86
87
|
let msg = `${data.type.trim()}`;
|
|
87
88
|
if (data.scope) {
|
|
88
89
|
msg += `(${data.scope.trim()})`;
|
|
@@ -90,7 +91,7 @@ async function createMsg(data) {
|
|
|
90
91
|
msg += `: ${data.description.trim()}`;
|
|
91
92
|
if (data.issue) {
|
|
92
93
|
// Hack to support Redmine ticket linking at work.
|
|
93
|
-
if (!
|
|
94
|
+
if (!isWork) {
|
|
94
95
|
msg += ` (#${data.issue})`;
|
|
95
96
|
}
|
|
96
97
|
else {
|
|
@@ -99,55 +100,5 @@ async function createMsg(data) {
|
|
|
99
100
|
}
|
|
100
101
|
return msg;
|
|
101
102
|
}
|
|
102
|
-
async function commit(msg) {
|
|
103
|
-
console.info('committing ...');
|
|
104
|
-
try {
|
|
105
|
-
await execute(`git commit -m "${msg}"`);
|
|
106
|
-
}
|
|
107
|
-
catch (err) {
|
|
108
|
-
console.error(err);
|
|
109
|
-
process.exit(1);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
async function isCurrentDirUnderGitControl() {
|
|
113
|
-
try {
|
|
114
|
-
const result = await execute('git rev-parse --is-inside-work-tree');
|
|
115
|
-
return result.trim() === 'true';
|
|
116
|
-
}
|
|
117
|
-
catch (err) {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
async function haveStagedChanges() {
|
|
122
|
-
try {
|
|
123
|
-
const staged = await execute('git diff --cached');
|
|
124
|
-
return staged !== '';
|
|
125
|
-
}
|
|
126
|
-
catch (err) {
|
|
127
|
-
console.error(err);
|
|
128
|
-
process.exit(1);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
async function isWork() {
|
|
132
|
-
try {
|
|
133
|
-
const output = await execute('git remote -v');
|
|
134
|
-
return output.includes('intra.bender:');
|
|
135
|
-
}
|
|
136
|
-
catch (err) {
|
|
137
|
-
console.error(err);
|
|
138
|
-
process.exit(1);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
async function execute(cmd) {
|
|
142
|
-
return new Promise((resolve, reject) => {
|
|
143
|
-
(0, child_process_1.exec)(cmd, (err, stdout) => {
|
|
144
|
-
if (err) {
|
|
145
|
-
reject(err);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
resolve(stdout);
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
103
|
main().catch(console.error);
|
|
153
104
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4s1/conventional-commit-creator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Conventional Commit Creator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"conventional commit",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"prompts": "^2.4.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@4s1/eslint-config": "3.
|
|
52
|
+
"@4s1/eslint-config": "3.5.0",
|
|
53
53
|
"@4s1/ts-config": "1.4.0",
|
|
54
|
-
"@commitlint/cli": "
|
|
55
|
-
"@commitlint/config-conventional": "
|
|
54
|
+
"@commitlint/cli": "16.0.0",
|
|
55
|
+
"@commitlint/config-conventional": "16.0.0",
|
|
56
56
|
"@types/jest": "27.0.3",
|
|
57
|
-
"@types/node": "14.18.
|
|
57
|
+
"@types/node": "14.18.2",
|
|
58
58
|
"@types/prompts": "2.4.0",
|
|
59
59
|
"eslint": "8.5.0",
|
|
60
60
|
"husky": "7.0.4",
|