@4s1/conventional-commit-creator 1.0.0 → 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/LICENSE +0 -0
- package/README.md +0 -0
- package/dist/git.d.ts +0 -0
- package/dist/git.d.ts.map +0 -0
- package/dist/git.js +3 -7
- package/dist/git.js.map +1 -1
- package/dist/index.d.ts +0 -0
- package/dist/index.d.ts.map +0 -0
- package/dist/index.js +4 -9
- package/dist/index.js.map +1 -1
- package/package.json +26 -23
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/dist/git.d.ts
CHANGED
|
File without changes
|
package/dist/git.d.ts.map
CHANGED
|
File without changes
|
package/dist/git.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts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,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
CHANGED
|
File without changes
|
package/dist/index.d.ts.map
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
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
|
{
|
|
@@ -62,7 +57,7 @@ const questions = [
|
|
|
62
57
|
},
|
|
63
58
|
];
|
|
64
59
|
async function main() {
|
|
65
|
-
const git = new
|
|
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 (
|
|
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":"
|
|
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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IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC;KACjC;IAED,GAAG,IAAI,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC;IAEtC,IAAI,IAAI,CAAC,KAAK,EAAE;QACd,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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4s1/conventional-commit-creator",
|
|
3
|
-
"version": "
|
|
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": "
|
|
18
|
+
"type": "module",
|
|
19
19
|
"exports": "./dist/index.js",
|
|
20
20
|
"main": "./dist/index.js",
|
|
21
21
|
"typings": "./dist/index.d.ts",
|
|
@@ -26,34 +26,37 @@
|
|
|
26
26
|
"files": [
|
|
27
27
|
"dist/"
|
|
28
28
|
],
|
|
29
|
-
"prettier": "@4s1/eslint-config",
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"prompts": "^2.4.2"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@4s1/eslint-config": "3.14.1",
|
|
35
|
-
"@4s1/ts-config": "2.0.0",
|
|
36
|
-
"@types/node": "14.18.22",
|
|
37
|
-
"@types/prompts": "2.4.0",
|
|
38
|
-
"eslint": "8.20.0",
|
|
39
|
-
"prettier": "2.7.1",
|
|
40
|
-
"ts-node": "10.9.1",
|
|
41
|
-
"typescript": "4.7.4"
|
|
42
|
-
},
|
|
43
|
-
"publishConfig": {
|
|
44
|
-
"access": "public",
|
|
45
|
-
"registry": "https://registry.npmjs.org"
|
|
46
|
-
},
|
|
47
29
|
"scripts": {
|
|
48
30
|
"build": "rm -rf dist && tsc",
|
|
49
31
|
"build:dev": "pnpm run build -- --project tsconfig.dev.json",
|
|
50
|
-
"format": "prettier --write
|
|
32
|
+
"format": "prettier --write .",
|
|
51
33
|
"lbt": "npm run lint && npm run build && npm run test",
|
|
52
|
-
"lint": "eslint --ext .ts src/",
|
|
34
|
+
"lint": "eslint --ext .ts src/ && prettier --check .",
|
|
53
35
|
"start": "node dist/index.js",
|
|
54
36
|
"start:dev": "ts-node src/index.ts",
|
|
55
37
|
"test": "echo no tests",
|
|
56
38
|
"test:cov": "pnpm run test -- --coverage",
|
|
57
39
|
"test:watch": "pnpm run test -- --watch"
|
|
40
|
+
},
|
|
41
|
+
"prettier": "@4s1/eslint-config",
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"prompts": "^2.4.2"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
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"
|
|
58
|
+
},
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public"
|
|
58
61
|
}
|
|
59
|
-
}
|
|
62
|
+
}
|