@4s1/conventional-commit-creator 0.13.1 → 2.0.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/dist/git.js CHANGED
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Git = void 0;
4
- const child_process_1 = require("child_process");
5
- class Git {
1
+ import { exec } from 'node:child_process';
2
+ export class Git {
6
3
  async isCurrentDirUnderGitControl() {
7
4
  try {
8
5
  const result = await this.execute('git rev-parse --is-inside-work-tree');
@@ -46,7 +43,7 @@ class Git {
46
43
  }
47
44
  execute(cmd) {
48
45
  return new Promise((resolve, reject) => {
49
- (0, child_process_1.exec)(cmd, (err, stdout) => {
46
+ exec(cmd, (err, stdout) => {
50
47
  if (err) {
51
48
  reject(err);
52
49
  return;
@@ -56,5 +53,4 @@ class Git {
56
53
  });
57
54
  }
58
55
  }
59
- exports.Git = Git;
60
56
  //# sourceMappingURL=git.js.map
package/dist/git.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":";;;AAAA,iDAAmD;AAEnD,MAAa,GAAG;IACP,KAAK,CAAC,2BAA2B;QACtC,IAAI;YACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAA;YACxE,OAAO,MAAM,CAAC,IAAI,EAAE,KAAK,MAAM,CAAA;SAChC;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAClB,OAAO,KAAK,CAAA;SACb;IACH,CAAC;IAEM,KAAK,CAAC,iBAAiB;QAC5B,IAAI;YACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAA;YAChE,OAAO,MAAM,KAAK,EAAE,CAAA;SACrB;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,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AC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAyB,EAAE,MAAc,EAAE,EAAE;gBACtD,IAAI,GAAG,EAAE;oBACP,MAAM,CAAC,GAAG,CAAC,CAAC;oBACZ,OAAO;iBACR;gBACD,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { exec, ExecException } from 'node:child_process';\n\nexport class Git {\n public async isCurrentDirUnderGitControl(): Promise<boolean> {\n try {\n const result = await this.execute('git rev-parse --is-inside-work-tree');\n return result.trim() === 'true';\n } catch (err) {\n console.error(err);\n return false;\n }\n }\n\n public async haveStagedChanges(): Promise<boolean> {\n try {\n const staged = await this.execute('git diff --cached | head -5');\n return staged !== '';\n } catch (err) {\n console.error(err);\n console.log('return false');\n return false;\n }\n }\n\n public async isAtWork(): Promise<boolean> {\n try {\n const output = await this.execute('git remote -v');\n return output.includes('intra.bender:');\n } catch (err) {\n console.error(err);\n return false;\n }\n }\n\n public async commit(msg: string): Promise<void> {\n console.info('committing ...');\n try {\n await this.execute(`git commit -m \"${msg}\"`);\n } catch (err) {\n console.error(err);\n process.exit(1);\n }\n }\n\n private execute(cmd: string): Promise<string> {\n return new Promise((resolve, reject) => {\n exec(cmd, (err: ExecException | null, stdout: string) => {\n if (err) {\n reject(err);\n return;\n }\n resolve(stdout);\n });\n });\n }\n}\n"]}
package/dist/index.js CHANGED
@@ -1,11 +1,6 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const prompts_1 = __importDefault(require("prompts"));
8
- const git_1 = require("./git");
2
+ import prompts from 'prompts';
3
+ import { Git } from './git.js';
9
4
  // https://kapeli.com/cheat_sheets/Conventional_Commits.docset/Contents/Resources/Documents/index
10
5
  const questions = [
11
6
  {
@@ -21,7 +16,7 @@ const questions = [
21
16
  { title: 'style - Code style (semicolon, indentation, white-space, formatting, ...)', value: 'style' },
22
17
  { title: 'test - add/change/delete tests', value: 'test' },
23
18
  { title: "chore - Other changes that don't modify src or test files", value: 'chore' },
24
- { title: 'build - build system (npm, git, VSCode, husky, tsconfig, ...)', value: 'build' },
19
+ { title: 'build - build system (npm, git, VSCode, tsconfig, ...)', value: 'build' },
25
20
  { title: 'ci - CI configuration (GitHub, GitLab, RenovateBot, ...)', value: 'ci' },
26
21
  { title: 'revert - Reverts a previous commit', value: 'revert' },
27
22
  ],
@@ -62,7 +57,7 @@ const questions = [
62
57
  },
63
58
  ];
64
59
  async function main() {
65
- const git = new git_1.Git();
60
+ const git = new Git();
66
61
  if (!(await git.isCurrentDirUnderGitControl())) {
67
62
  console.error('Current directory is not a git repository.');
68
63
  process.exit(0);
@@ -71,7 +66,7 @@ async function main() {
71
66
  console.error('Nothing to commit');
72
67
  process.exit(0);
73
68
  }
74
- const data = (await (0, prompts_1.default)(questions, {
69
+ const data = (await prompts(questions, {
75
70
  onCancel: () => {
76
71
  console.error('Aborted');
77
72
  process.exit(1);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAEA,sDAA+C;AAC/C,+BAA2B;AAS3B,iGAAiG;AACjG,MAAM,SAAS,GAAmB;IAChC;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAE,KAAK,EAAE;YAC9C,EAAE,KAAK,EAAE,0BAA0B,EAAE,KAAK,EAAE,MAAM,EAAE;YACpD,EAAE,KAAK,EAAE,sEAAsE,EAAE,KAAK,EAAE,UAAU,EAAE;YACpG,EAAE,KAAK,EAAE,oDAAoD,EAAE,K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ompts';\nimport { Git } from './git.js';\n\ntype promptType = {\n type: string;\n scope?: string;\n description: string;\n issue?: number;\n};\n\n// https://kapeli.com/cheat_sheets/Conventional_Commits.docset/Contents/Resources/Documents/index\nconst questions: PromptObject[] = [\n {\n type: 'select',\n name: 'type',\n message: 'type?',\n choices: [\n { title: 'fix - A bugfix', value: 'fix' },\n { title: 'feat - A new feature', value: 'feat' },\n { title: 'refactor - A code change that neither fixes a bug nor adds a feature', value: 'refactor' },\n { title: 'perf - A code change that improves performance', value: 'perf' },\n { title: 'docs - Documentation only changes', value: 'docs' },\n { title: 'style - Code style (semicolon, indentation, white-space, formatting, ...)', value: 'style' },\n { title: 'test - add/change/delete tests', value: 'test' },\n { title: \"chore - Other changes that don't modify src or test files\", value: 'chore' },\n { title: 'build - build system (npm, git, VSCode, tsconfig, ...)', value: 'build' },\n { title: 'ci - CI configuration (GitHub, GitLab, RenovateBot, ...)', value: 'ci' },\n { title: 'revert - Reverts a previous commit', value: 'revert' },\n ],\n },\n {\n type: 'text',\n name: 'scope',\n message: 'scope?',\n validate: (value: string): string | boolean => {\n if (value.length > 30) {\n return `Your text is ${value.length - 30} char(s) too long.`;\n } else {\n return true;\n }\n },\n },\n {\n type: 'text',\n name: 'description',\n message: 'description?',\n validate: (value: string): string | boolean => {\n if (value.length > 80) {\n return `Your text is ${value.length - 80} char(s) too long.`;\n } else if (value.length < 3) {\n return `Your text is ${3 - value.length} char(s) too short.`;\n } else {\n return true;\n }\n },\n },\n {\n type: 'number',\n name: 'issue',\n message: 'issue?',\n },\n];\n\nasync function main(): Promise<void> {\n const git = new Git();\n\n if (!(await git.isCurrentDirUnderGitControl())) {\n console.error('Current directory is not a git repository.');\n process.exit(0);\n }\n\n if (!(await git.haveStagedChanges())) {\n console.error('Nothing to commit');\n process.exit(0);\n }\n\n const data = (await prompts(questions, {\n onCancel: () => {\n console.error('Aborted');\n process.exit(1);\n },\n })) as promptType;\n\n const isAtWork = await git.isAtWork();\n const msg = await createMsg(data, isAtWork);\n await git.commit(msg);\n console.info('done');\n}\n\nasync function createMsg(data: promptType, isWork: boolean): Promise<string> {\n let msg = `${data.type.trim()}`;\n\n if (data.scope) {\n msg += `(${data.scope.trim()})`;\n }\n\n msg += `: ${data.description.trim()}`;\n\n if (data.issue) {\n // Hack to support Redmine ticket linking at work.\n if (!isWork) {\n msg += ` (#${data.issue})`;\n } else {\n msg += ` [refs #${data.issue}]`;\n }\n }\n\n return msg;\n}\n\nmain().catch(console.error);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4s1/conventional-commit-creator",
3
- "version": "0.13.1",
3
+ "version": "2.0.0",
4
4
  "description": "Conventional Commit Creator",
5
5
  "keywords": [
6
6
  "conventional commit",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "license": "MIT",
17
17
  "author": "Steffen <steffen@4s1.de>",
18
- "type": "commonjs",
18
+ "type": "module",
19
19
  "exports": "./dist/index.js",
20
20
  "main": "./dist/index.js",
21
21
  "typings": "./dist/index.d.ts",
@@ -29,14 +29,9 @@
29
29
  "scripts": {
30
30
  "build": "rm -rf dist && tsc",
31
31
  "build:dev": "pnpm run build -- --project tsconfig.dev.json",
32
- "format": "prettier --write src/",
32
+ "format": "prettier --write .",
33
33
  "lbt": "npm run lint && npm run build && npm run test",
34
- "lint": "eslint --ext .ts src/",
35
- "prepare": "husky install",
36
- "release": "git diff --exit-code --quiet && pnpm run lbt && standard-version",
37
- "release:major": "pnpm run release -- --release-as major",
38
- "release:minor": "pnpm run release -- --release-as minor",
39
- "release:patch": "pnpm run release -- --release-as patch",
34
+ "lint": "eslint --ext .ts src/ && prettier --check .",
40
35
  "start": "node dist/index.js",
41
36
  "start:dev": "ts-node src/index.ts",
42
37
  "test": "echo no tests",
@@ -48,21 +43,20 @@
48
43
  "prompts": "^2.4.2"
49
44
  },
50
45
  "devDependencies": {
51
- "@4s1/eslint-config": "3.11.0",
52
- "@4s1/ts-config": "1.4.0",
53
- "@commitlint/cli": "16.2.3",
54
- "@commitlint/config-conventional": "16.2.1",
55
- "@types/node": "14.18.12",
56
- "@types/prompts": "2.4.0",
57
- "eslint": "8.12.0",
58
- "husky": "7.0.4",
59
- "prettier": "2.6.2",
60
- "standard-version": "9.3.2",
61
- "ts-node": "10.7.0",
62
- "typescript": "4.6.3"
46
+ "@4s1/eslint-config": "4.3.0",
47
+ "@4s1/ts-config": "3.0.1",
48
+ "@types/node": "18.11.18",
49
+ "@types/prompts": "2.4.2",
50
+ "eslint": "8.31.0",
51
+ "prettier": "2.8.2",
52
+ "ts-node": "10.9.1",
53
+ "typescript": "4.9.4"
54
+ },
55
+ "engines": {
56
+ "node": "18",
57
+ "pnpm": "7"
63
58
  },
64
59
  "publishConfig": {
65
- "access": "public",
66
- "registry": "https://registry.npmjs.org"
60
+ "access": "public"
67
61
  }
68
62
  }
package/CHANGELOG.md DELETED
@@ -1,129 +0,0 @@
1
- # Changelog
2
-
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
-
5
- ## [0.13.1](https://github.com/4s1-org/conventional-commit-creator/compare/v0.13.0...v0.13.1) (2022-04-05)
6
-
7
- ## [0.13.0](https://github.com/4s1-org/conventional-commit-creator/compare/v0.12.0...v0.13.0) (2022-04-01)
8
-
9
- ### Features
10
-
11
- - renaming type texts ([e87ce5b](https://github.com/4s1-org/conventional-commit-creator/commit/e87ce5bcceede74620fd8fec3434a25c95e43c34))
12
-
13
- ## [0.12.0](https://github.com/4s1-org/conventional-commit-creator/compare/v0.11.3...v0.12.0) (2022-03-11)
14
-
15
- ### Features
16
-
17
- - first letter in description can be in upper case ([67964f3](https://github.com/4s1-org/conventional-commit-creator/commit/67964f3afb131376ef26b11c634565de521cc7b3))
18
-
19
- ## [0.11.3](https://github.com/4s1-org/conventional-commit-creator/compare/v0.11.2...v0.11.3) (2021-12-28)
20
-
21
- ### Bug Fixes
22
-
23
- - add whole dist folder ([3d1cd01](https://github.com/4s1-org/conventional-commit-creator/commit/3d1cd01ab20554064de6a2ad3035a96e4f4db9b3))
24
-
25
- ## [0.11.2](https://github.com/4s1-org/conventional-commit-creator/compare/v0.11.1...v0.11.2) (2021-12-28)
26
-
27
- ### Bug Fixes
28
-
29
- - add shebang ([6cc8f2c](https://github.com/4s1-org/conventional-commit-creator/commit/6cc8f2cd0dc20eaef6e11945e8a83bbaec0b6652))
30
-
31
- ## [0.11.1](https://github.com/4s1-org/conventional-commit-creator/compare/v0.11.0...v0.11.1) (2021-12-26)
32
-
33
- ### Bug Fixes
34
-
35
- - large amount of changes supported ([#5](https://github.com/4s1-org/conventional-commit-creator/issues/5)) ([db17314](https://github.com/4s1-org/conventional-commit-creator/commit/db173145a42fcd7f4e701b8a4f413c89f890c680))
36
-
37
- ## [0.11.0](https://github.com/4s1-org/conventional-commit-creator/compare/v0.10.2...v0.11.0) (2021-12-26)
38
-
39
- ## [0.10.2](https://github.com/4s1-org/conventional-commit-creator/compare/v0.9.0...v0.10.2) (2021-12-21)
40
-
41
- ### Bug Fixes
42
-
43
- - add check if current dir is a git repository ([#4](https://github.com/4s1-org/conventional-commit-creator/issues/4)) ([75d34be](https://github.com/4s1-org/conventional-commit-creator/commit/75d34be610e1ef6500d970f8c32464da0bf2d6a3))
44
- - add missing await statement and rename function ([04892a0](https://github.com/4s1-org/conventional-commit-creator/commit/04892a0e1a9566c0b53895036792001a8e42b00f))
45
- - **git:** repair check if current dir is under git ([419d422](https://github.com/4s1-org/conventional-commit-creator/commit/419d42222a648ea9437a42589a9a9ad404a144ba))
46
-
47
- ## [0.10.1](https://github.com/4s1-org/conventional-commit-creator/compare/v0.10.0...v0.10.1) (2021-12-18)
48
-
49
- ### Bug Fixes
50
-
51
- - add check if current dir is a git repository ([#4](https://github.com/4s1-org/conventional-commit-creator/issues/4)) ([75d34be](https://github.com/4s1-org/conventional-commit-creator/commit/75d34be610e1ef6500d970f8c32464da0bf2d6a3))
52
- - add missing await statement and rename function ([04892a0](https://github.com/4s1-org/conventional-commit-creator/commit/04892a0e1a9566c0b53895036792001a8e42b00f))
53
-
54
- ## [0.10.0](https://github.com/4s1-org/conventional-commit-creator/compare/v0.9.0...v0.10.0) (2021-12-15)
55
-
56
- ## [0.9.0](https://github.com/4s1-org/conventional-commit-creator/compare/v0.8.0...v0.9.0) (2021-12-10)
57
-
58
- ## [0.8.0](https://github.com/4s1-org/conventional-commit-creator/compare/v0.7.0...v0.8.0) (2021-11-18)
59
-
60
- ### Features
61
-
62
- - add hack for redmine at work ([538273e](https://github.com/4s1-org/conventional-commit-creator/commit/538273e997c074bb28c877571b68e82a9d3fff52))
63
-
64
- ## [0.7.0](https://github.com/4s1-org/conventional-commit-creator/compare/v0.6.0...v0.7.0) (2021-11-18)
65
-
66
- ### Features
67
-
68
- - remove brackets from issue ([cbaca2f](https://github.com/4s1-org/conventional-commit-creator/commit/cbaca2f05ac80731ecf2b6a10c19ccf993df20c5))
69
- - **svn:** remove support for git svn ([e3a2dff](https://github.com/4s1-org/conventional-commit-creator/commit/e3a2dff303a46e089363fcb46b10f8e045a5c72a))
70
-
71
- ## [0.6.0](https://github.com/4s1-org/conventional-commit-creator/compare/v0.5.1...v0.6.0) (2021-11-13)
72
-
73
- ### Features
74
-
75
- - better description of types ([299226b](https://github.com/4s1-org/conventional-commit-creator/commit/299226bbfbcf9272ffe25c0c0e7a7a7dfc518ae2))
76
-
77
- ## [0.5.1](https://github.com/4s1-org/conventional-commit-creator/compare/v0.5.0...v0.5.1) (2021-11-05)
78
-
79
- ### Bug Fixes
80
-
81
- - add missing quotation marks ([424a696](https://github.com/4s1-org/conventional-commit-creator/commit/424a69648d428f908c6a693af9b3e4af2f3f2007))
82
-
83
- ## [0.5.0](https://github.com/4s1-org/conventional-commit-creator/compare/v0.4.1...v0.5.0) (2021-11-05)
84
-
85
- ### Features
86
-
87
- - allow 30 chars for scope ([b680d47](https://github.com/4s1-org/conventional-commit-creator/commit/b680d47a00b027d2b892392376b9beeb1952d083))
88
- - remove zx as dependencies and code cleanup ([76b52ac](https://github.com/4s1-org/conventional-commit-creator/commit/76b52ac0328dc4fe5ea66240f639c5bd0636de9e))
89
- - reorder types ([ff83593](https://github.com/4s1-org/conventional-commit-creator/commit/ff83593e98521f065291ccbd597290a20c2029e9))
90
-
91
- ## [0.4.1](https://github.com/4s1-org/conventional-commit-creator/compare/v0.4.0...v0.4.1) (2021-11-05)
92
-
93
- ### Bug Fixes
94
-
95
- - rename body to description ([f56f50d](https://github.com/4s1-org/conventional-commit-creator/commit/f56f50d0cea7567d5e04f08520896b299c4f700a))
96
-
97
- ## [0.4.0](https://github.com/4s1-org/conventional-commit-creator/compare/v0.2.0...v0.4.0) (2021-11-02)
98
-
99
- ### Features
100
-
101
- - reformat type selection ([48c47f4](https://github.com/4s1-org/conventional-commit-creator/commit/48c47f4526fc20e81382ab226736ce8b8c476bc2))
102
- - trim type, scope and description ([ea08f8d](https://github.com/4s1-org/conventional-commit-creator/commit/ea08f8d5783b30ad6ca66f35ab452aff13f55120))
103
-
104
- ## [0.3.0](https://github.com/4s1-org/conventional-commit-creator/compare/v0.2.0...v0.3.0) (2021-11-02)
105
-
106
- ### Features
107
-
108
- - reformat type selection ([9573f94](https://github.com/4s1-org/conventional-commit-creator/commit/9573f94080963bfd923909e9c683f6da2ec46a72))
109
-
110
- ## [0.2.0](https://github.com/4s1-org/conventional-commit-creator/compare/v0.1.1...v0.2.0) (2021-11-02)
111
-
112
- ### Features
113
-
114
- - add exception handling ([ba75df3](https://github.com/4s1-org/conventional-commit-creator/commit/ba75df386b0554781a45b6e203a85bd5c7e9200b))
115
- - add output message while committing ([c55711e](https://github.com/4s1-org/conventional-commit-creator/commit/c55711e555c3c31afbf0d5af179d60677e65b2d9))
116
- - **fg:** undefined ([182c69e](https://github.com/4s1-org/conventional-commit-creator/commit/182c69efc362fb98053b9198b0eab7ab516dcf37))
117
- - more exception handling ([76ffdd8](https://github.com/4s1-org/conventional-commit-creator/commit/76ffdd863b779670dfc13fb8df5be01d687e5f8e))
118
-
119
- ### Bug Fixes
120
-
121
- - remove icons ([b8e4043](https://github.com/4s1-org/conventional-commit-creator/commit/b8e4043eb492dc89e7294184088185378b0aa414))
122
-
123
- ## [0.1.1](https://github.com/4s1-org/conventional-commit-creator/compare/v0.1.0...v0.1.1) (2021-11-02)
124
-
125
- ## 0.1.0 (2021-11-02)
126
-
127
- ### Features
128
-
129
- - first implementation ([1d8dfca](https://github.com/4s1-org/conventional-commit-creator/commit/1d8dfca8a0f4099155a072d86f24bc4b7c92f509))