@4s1/conventional-commit-creator 2.0.0 → 2.0.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/LICENSE +1 -1
- package/README.md +0 -4
- package/dist/git.js +4 -2
- package/dist/index.js +0 -1
- package/package.json +11 -12
- package/dist/git.d.ts +0 -8
- package/dist/git.d.ts.map +0 -1
- package/dist/git.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
[](https://sonarcloud.io/project/issues?id=4s1_conventional-commit-creator&resolved=false&types=BUG)
|
|
2
|
-
[](https://sonarcloud.io/project/issues?id=4s1_conventional-commit-creator&resolved=false&types=VULNERABILITY)
|
|
3
|
-
[](https://sonarcloud.io/project/issues?id=4s1_conventional-commit-creator&resolved=false&types=CODE_SMELL)
|
|
4
|
-
|
|
5
1
|
# Conventional Commit Creator
|
|
6
2
|
|
|
7
3
|
This CLI application assists in creating commit messages that are conform to the conventional commit style.
|
package/dist/git.js
CHANGED
|
@@ -34,13 +34,16 @@ export class Git {
|
|
|
34
34
|
async commit(msg) {
|
|
35
35
|
console.info('committing ...');
|
|
36
36
|
try {
|
|
37
|
-
await this.execute(`git commit -m "${msg}"`);
|
|
37
|
+
await this.execute(`git commit -m "${this.encodeMessage(msg)}"`);
|
|
38
38
|
}
|
|
39
39
|
catch (err) {
|
|
40
40
|
console.error(err);
|
|
41
41
|
process.exit(1);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
encodeMessage(msg) {
|
|
45
|
+
return msg.replaceAll('"', '\\"');
|
|
46
|
+
}
|
|
44
47
|
execute(cmd) {
|
|
45
48
|
return new Promise((resolve, reject) => {
|
|
46
49
|
exec(cmd, (err, stdout) => {
|
|
@@ -53,4 +56,3 @@ export class Git {
|
|
|
53
56
|
});
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
|
-
//# sourceMappingURL=git.js.map
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4s1/conventional-commit-creator",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Conventional Commit Creator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"conventional commit",
|
|
@@ -29,9 +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 .",
|
|
33
32
|
"lbt": "npm run lint && npm run build && npm run test",
|
|
34
33
|
"lint": "eslint --ext .ts src/ && prettier --check .",
|
|
34
|
+
"lint:fix": "eslint --ext .ts --fix src/ && prettier --write .",
|
|
35
35
|
"start": "node dist/index.js",
|
|
36
36
|
"start:dev": "ts-node src/index.ts",
|
|
37
37
|
"test": "echo no tests",
|
|
@@ -40,21 +40,20 @@
|
|
|
40
40
|
},
|
|
41
41
|
"prettier": "@4s1/eslint-config",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"prompts": "
|
|
43
|
+
"prompts": "2.4.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@4s1/eslint-config": "
|
|
47
|
-
"@4s1/ts-config": "
|
|
48
|
-
"@types/node": "18.11
|
|
49
|
-
"@types/prompts": "2.4.
|
|
50
|
-
"eslint": "8.
|
|
51
|
-
"prettier": "2.8.
|
|
46
|
+
"@4s1/eslint-config": "6.5.0",
|
|
47
|
+
"@4s1/ts-config": "4.1.1",
|
|
48
|
+
"@types/node": "18.15.11",
|
|
49
|
+
"@types/prompts": "2.4.4",
|
|
50
|
+
"eslint": "8.38.0",
|
|
51
|
+
"prettier": "2.8.7",
|
|
52
52
|
"ts-node": "10.9.1",
|
|
53
|
-
"typescript": "
|
|
53
|
+
"typescript": "5.0.4"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
|
-
"node": "18"
|
|
57
|
-
"pnpm": "7"
|
|
56
|
+
"node": "18"
|
|
58
57
|
},
|
|
59
58
|
"publishConfig": {
|
|
60
59
|
"access": "public"
|
package/dist/git.d.ts
DELETED
package/dist/git.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAEA,qBAAa,GAAG;IACD,2BAA2B,IAAI,OAAO,CAAC,OAAO,CAAC;IAU/C,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;IAWrC,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAU5B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU/C,OAAO,CAAC,OAAO;CAWhB"}
|
package/dist/git.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAiB,MAAM,oBAAoB,CAAC;AAEzD,MAAM,OAAO,GAAG;IACP,KAAK,CAAC,2BAA2B;QACtC,IAAI;YACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAC;YACzE,OAAO,MAAM,CAAC,IAAI,EAAE,KAAK,MAAM,CAAC;SACjC;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,OAAO,KAAK,CAAC;SACd;IACH,CAAC;IAEM,KAAK,CAAC,iBAAiB;QAC5B,IAAI;YACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC;YACjE,OAAO,MAAM,KAAK,EAAE,CAAC;SACtB;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC5B,OAAO,KAAK,CAAC;SACd;IACH,CAAC;IAEM,KAAK,CAAC,QAAQ;QACnB,IAAI;YACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;YACnD,OAAO,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;SACzC;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,OAAO,KAAK,CAAC;SACd;IACH,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,GAAW;QAC7B,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC/B,IAAI;YACF,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,GAAG,GAAG,CAAC,CAAC;SAC9C;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;IACH,CAAC;IAEO,OAAO,CAAC,GAAW;QACzB,OAAO,IAAI,OAAO,CAAC,CAAC,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.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,OAAyB,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAS/B,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,KAAK,EAAE,MAAM,EAAE;YAC9E,EAAE,KAAK,EAAE,uCAAuC,EAAE,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,kDAAkD;QAClD,IAAI,CAAC,MAAM,EAAE;YACX,GAAG,IAAI,MAAM,IAAI,CAAC,KAAK,GAAG,CAAC;SAC5B;aAAM;YACL,GAAG,IAAI,WAAW,IAAI,CAAC,KAAK,GAAG,CAAC;SACjC;KACF;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport prompts, { PromptObject } from 'prompts';\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"]}
|