@4s1/conventional-commit-creator 0.10.0 → 0.10.1

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 CHANGED
@@ -2,6 +2,14 @@
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.10.1](https://gitlab.com/4s1/conventional-commit-creator/compare/v0.10.0...v0.10.1) (2021-12-18)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * add check if current dir is a git repository ([#4](https://gitlab.com/4s1/conventional-commit-creator/issues/4)) ([75d34be](https://gitlab.com/4s1/conventional-commit-creator/commit/75d34be610e1ef6500d970f8c32464da0bf2d6a3))
11
+ * add missing await statement and rename function ([04892a0](https://gitlab.com/4s1/conventional-commit-creator/commit/04892a0e1a9566c0b53895036792001a8e42b00f))
12
+
5
13
  ## [0.10.0](https://gitlab.com/4s1/conventional-commit-creator/compare/v0.9.0...v0.10.0) (2021-12-15)
6
14
 
7
15
  ## [0.9.0](https://gitlab.com/4s1/conventional-commit-creator/compare/v0.8.0...v0.9.0) (2021-12-10)
package/README.md CHANGED
@@ -3,6 +3,8 @@
3
3
  This CLI application assists in creating commit messages that are conform to the conventional commit style.
4
4
  It will ask for type, scope (optional), description and issue (optional).
5
5
 
6
+ ![Usage](https://gitlab.com/4s1/conventional-commit-creator/-/raw/main/_docs/usage.gif 'Usage')
7
+
6
8
  ## Install
7
9
 
8
10
  ```bash
package/dist/index.js CHANGED
@@ -64,28 +64,33 @@ const questions = [
64
64
  },
65
65
  ];
66
66
  async function main() {
67
+ if (!(await isCurrentDirUnderGitControl())) {
68
+ console.error('Current directory is not a git repository.');
69
+ process.exit(0);
70
+ }
67
71
  if (!(await haveStagedChanges())) {
68
72
  console.error('Nothing to commit');
69
73
  process.exit(0);
70
74
  }
71
- const data = await (0, prompts_1.default)(questions, {
75
+ const data = (await (0, prompts_1.default)(questions, {
72
76
  onCancel: () => {
73
77
  console.error('Aborted');
74
78
  process.exit(1);
75
79
  },
76
- });
77
- const msg = createMsg(data);
80
+ }));
81
+ const msg = await createMsg(data);
78
82
  await commit(msg);
79
83
  console.info('done');
80
84
  }
81
- function createMsg(data) {
85
+ async function createMsg(data) {
82
86
  let msg = `${data.type.trim()}`;
83
87
  if (data.scope) {
84
88
  msg += `(${data.scope.trim()})`;
85
89
  }
86
90
  msg += `: ${data.description.trim()}`;
87
91
  if (data.issue) {
88
- if (!isBender()) {
92
+ // Hack to support Redmine ticket linking at work.
93
+ if (!(await isWork())) {
89
94
  msg += ` (#${data.issue})`;
90
95
  }
91
96
  else {
@@ -104,6 +109,15 @@ async function commit(msg) {
104
109
  process.exit(1);
105
110
  }
106
111
  }
112
+ async function isCurrentDirUnderGitControl() {
113
+ try {
114
+ const result = await execute('git rev-parse --is-inside-work-tree');
115
+ return result === 'true';
116
+ }
117
+ catch (err) {
118
+ return false;
119
+ }
120
+ }
107
121
  async function haveStagedChanges() {
108
122
  try {
109
123
  const staged = await execute('git diff --cached');
@@ -114,7 +128,7 @@ async function haveStagedChanges() {
114
128
  process.exit(1);
115
129
  }
116
130
  }
117
- async function isBender() {
131
+ async function isWork() {
118
132
  try {
119
133
  const output = await execute('git remote -v');
120
134
  return output.includes('intra.bender:');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4s1/conventional-commit-creator",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Conventional Commit Creator",
5
5
  "keywords": [
6
6
  "conventional commit",
@@ -40,23 +40,28 @@
40
40
  "release:patch": "pnpm run release -- --release-as patch",
41
41
  "start": "node dist/index.js",
42
42
  "start:dev": "ts-node src/index.ts",
43
- "test": "echo no tests"
43
+ "test": "jest",
44
+ "test:cov": "pnpm run test -- --coverage",
45
+ "test:watch": "pnpm run test -- --watch"
44
46
  },
45
47
  "prettier": "@4s1/eslint-config",
46
48
  "dependencies": {
47
49
  "prompts": "^2.4.2"
48
50
  },
49
51
  "devDependencies": {
50
- "@4s1/eslint-config": "^3.4.0",
51
- "@4s1/ts-config": "^1.4.0",
52
+ "@4s1/eslint-config": "3.4.0",
53
+ "@4s1/ts-config": "1.4.0",
52
54
  "@commitlint/cli": "15.0.0",
53
55
  "@commitlint/config-conventional": "15.0.0",
54
- "@types/node": "14.18.0",
56
+ "@types/jest": "27.0.3",
57
+ "@types/node": "14.18.1",
55
58
  "@types/prompts": "2.4.0",
56
- "eslint": "8.4.1",
59
+ "eslint": "8.5.0",
57
60
  "husky": "7.0.4",
61
+ "jest": "27.4.5",
58
62
  "prettier": "2.5.1",
59
63
  "standard-version": "9.3.2",
64
+ "ts-jest": "27.1.2",
60
65
  "ts-node": "10.4.0",
61
66
  "typescript": "4.5.4"
62
67
  },