format-commit 0.2.2 → 0.3.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/README.md +43 -15
- package/lib/commit.js +0 -1
- package/lib/default-config.json +1 -1
- package/lib/index.js +22 -7
- package/lib/options.json +6 -6
- package/package.json +35 -25
package/README.md
CHANGED
|
@@ -1,33 +1,61 @@
|
|
|
1
1
|
# format-commit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://badge.fury.io/js/format-commit)
|
|
4
|
+
[](https://nodejs.org/)
|
|
5
|
+
[](https://www.npmjs.com/package/format-commit)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
🚀 Lightweight CLI for consistent commit message formatting.
|
|
9
|
+
|
|
10
|
+
Standardize your commit naming with basic rules, and guide your workflow through an automated script. No bloat, no complexity — just clean, consistent commits.
|
|
4
11
|
|
|
5
12
|
## Installation
|
|
6
13
|
|
|
7
14
|
```sh
|
|
8
|
-
|
|
15
|
+
npm i format-commit --save-dev
|
|
9
16
|
```
|
|
10
17
|
|
|
11
18
|
## Usage
|
|
12
19
|
|
|
13
|
-
|
|
20
|
+
Add to your `package.json` scripts:
|
|
21
|
+
```json
|
|
22
|
+
"scripts": {
|
|
23
|
+
"commit": "format-commit"
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Then use:
|
|
28
|
+
```sh
|
|
29
|
+
npm run commit
|
|
30
|
+
```
|
|
14
31
|
|
|
15
|
-
Or install
|
|
32
|
+
Or install globally:
|
|
33
|
+
```sh
|
|
34
|
+
npm i -g format-commit
|
|
35
|
+
format-commit
|
|
36
|
+
```
|
|
16
37
|
|
|
17
|
-
|
|
38
|
+
On first use, format-commit will prompt you to configure your commit format and create a `commit-config.json` file.
|
|
18
39
|
|
|
19
|
-
|
|
40
|
+
To reconfigure later, run:
|
|
41
|
+
```sh
|
|
42
|
+
format-commit --config
|
|
43
|
+
```
|
|
20
44
|
|
|
21
45
|
## Configuration
|
|
22
46
|
|
|
23
47
|
| Property | Description |
|
|
24
48
|
| :------- | :---------- |
|
|
25
|
-
| **format** |
|
|
26
|
-
| **types** |
|
|
27
|
-
| **scopes** |
|
|
28
|
-
| **minLength** | Minimum
|
|
29
|
-
| **maxLength** | Maximum
|
|
30
|
-
| **changeVersion** |
|
|
31
|
-
| **releaseBranch** |
|
|
32
|
-
| **showAllVersionTypes** | Show all
|
|
33
|
-
| **stageAllChanges** | Auto-stage all changes before
|
|
49
|
+
| **format** | Commit title format:<br>1 - `(type) Name` / 2 - `(type) name`<br>3 - `type: Name` / 4 - `type: name`<br>5 - `type(scope) Name` / 6 - `type(scope) name`<br>7 - `type(scope): Name` / 8 - `type(scope): name` |
|
|
50
|
+
| **types** | Allowed commit types (default: `feat`, `fix`, `core`, `test`, `config`, `doc`) |
|
|
51
|
+
| **scopes** | Scopes for commit categorization (formats 5-8 only) |
|
|
52
|
+
| **minLength** | Minimum length required for the commit title |
|
|
53
|
+
| **maxLength** | Maximum length required for the commit title |
|
|
54
|
+
| **changeVersion** | Version change policy:<br>`never` - Always prompt for version change<br>`only on release branch` - Only release branch commits require version change<br>`always` - All commits require version change |
|
|
55
|
+
| **releaseBranch** | Main/release branch name (used if changeVersion = `only on release branch`) |
|
|
56
|
+
| **showAllVersionTypes** | Show all version types or only main ones (`major`/`minor`/`patch`/`custom`) |
|
|
57
|
+
| **stageAllChanges** | Auto-stage all changes before commit ⚠️ |
|
|
58
|
+
|
|
59
|
+
## Contributing
|
|
60
|
+
|
|
61
|
+
Contributions are welcome! Feel free to open issues or submit pull requests.
|
package/lib/commit.js
CHANGED
|
@@ -75,7 +75,6 @@ module.exports = async (config, testMode) => {
|
|
|
75
75
|
choices: config.showAllVersionTypes
|
|
76
76
|
? [...options.versionTypes, ...options.allVersionTypes]
|
|
77
77
|
: options.versionTypes,
|
|
78
|
-
initial: currentBranch === config.releaseBranch ? 1 : 2,
|
|
79
78
|
},
|
|
80
79
|
{
|
|
81
80
|
type: prev => prev === 'custom' ? 'text' : null,
|
package/lib/default-config.json
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,22 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
const {
|
|
4
|
+
const { Command } = require('commander');
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const utils = require('./utils');
|
|
7
7
|
const setup = require('./setup');
|
|
8
8
|
const commit = require('./commit');
|
|
9
9
|
const options = require('./options.json');
|
|
10
10
|
|
|
11
|
-
program
|
|
12
|
-
|
|
13
|
-
program
|
|
11
|
+
const program = new Command();
|
|
12
|
+
|
|
13
|
+
program
|
|
14
|
+
.name('format-commit')
|
|
15
|
+
.description('CLI to standardize commit nomenclature')
|
|
16
|
+
.version('0.3.1')
|
|
17
|
+
.option('-c, --config', 'generate a configuration file on your project for format-commit')
|
|
18
|
+
.option('-t, --test', 'start script without finalize commit (for tests)');
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
program.parse(process.argv);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error('Error parsing arguments:', error.message);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
14
26
|
|
|
15
27
|
(async () => {
|
|
16
|
-
|
|
28
|
+
const opts = program.opts();
|
|
29
|
+
|
|
30
|
+
if (opts.config) {
|
|
17
31
|
await setup(false);
|
|
18
32
|
return;
|
|
19
33
|
}
|
|
34
|
+
|
|
20
35
|
/**
|
|
21
36
|
* Get config from consumer package root
|
|
22
37
|
* Generate new config file if not founded
|
|
@@ -26,10 +41,10 @@ program.parse(process.argv);
|
|
|
26
41
|
utils.log('no configuration found', 'warning');
|
|
27
42
|
const setupResult = await setup(true);
|
|
28
43
|
if (setupResult && setupResult.commitAfter) {
|
|
29
|
-
commit(setupResult.config,
|
|
44
|
+
commit(setupResult.config, opts.test);
|
|
30
45
|
}
|
|
31
46
|
} else {
|
|
32
|
-
commit(JSON.parse(data),
|
|
47
|
+
commit(JSON.parse(data), opts.test);
|
|
33
48
|
}
|
|
34
49
|
});
|
|
35
50
|
})();
|
package/lib/options.json
CHANGED
|
@@ -11,20 +11,20 @@
|
|
|
11
11
|
{ "value": 8, "title": "type(scope): name" }
|
|
12
12
|
],
|
|
13
13
|
"versionChangeMode": [
|
|
14
|
-
{ "value": "always" },
|
|
14
|
+
{ "value": "never", "title": "never (always ask)" },
|
|
15
15
|
{ "value": "releaseBranch", "title": "only on release branch" },
|
|
16
|
-
{ "value": "
|
|
16
|
+
{ "value": "always" }
|
|
17
17
|
],
|
|
18
18
|
"versionTypes": [
|
|
19
|
-
{ "value": "major" },
|
|
20
|
-
{ "value": "minor" },
|
|
21
19
|
{ "value": "patch" },
|
|
20
|
+
{ "value": "minor" },
|
|
21
|
+
{ "value": "major" },
|
|
22
22
|
{ "value": "custom", "title": "<custom>" }
|
|
23
23
|
],
|
|
24
24
|
"allVersionTypes": [
|
|
25
|
-
{ "value": "premajor" },
|
|
26
|
-
{ "value": "preminor" },
|
|
27
25
|
{ "value": "prepatch" },
|
|
26
|
+
{ "value": "preminor" },
|
|
27
|
+
{ "value": "premajor" },
|
|
28
28
|
{ "value": "prerelease", "title": "prerelease <tag>" },
|
|
29
29
|
{ "value": "from-git" }
|
|
30
30
|
]
|
package/package.json
CHANGED
|
@@ -1,15 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "format-commit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Lightweight CLI to standardize commit messages",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "Thomas BARKATS",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"git",
|
|
9
|
+
"commit",
|
|
10
|
+
"commits",
|
|
11
|
+
"cli",
|
|
12
|
+
"format",
|
|
13
|
+
"standardize",
|
|
14
|
+
"conventional",
|
|
15
|
+
"semantic",
|
|
16
|
+
"workflow",
|
|
17
|
+
"tool",
|
|
18
|
+
"javascript",
|
|
19
|
+
"nodejs"
|
|
20
|
+
],
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/thomasbarkats/format-commit.git"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/thomasbarkats/format-commit#readme",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/thomasbarkats/format-commit/issues"
|
|
28
|
+
},
|
|
5
29
|
"main": "./lib/index.js",
|
|
6
30
|
"type": "commonjs",
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=16.0.0"
|
|
33
|
+
},
|
|
7
34
|
"scripts": {
|
|
8
35
|
"start": "node lib/index.js",
|
|
9
36
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
37
|
"lint": "eslint . --ext .js --fix",
|
|
11
38
|
"prepublishOnly": "npm run lint",
|
|
12
|
-
"preversion": "npm run lint"
|
|
39
|
+
"preversion": "npm run lint",
|
|
40
|
+
"commit": "npm run lint && npm run start"
|
|
13
41
|
},
|
|
14
42
|
"files": [
|
|
15
43
|
"lib/**/*"
|
|
@@ -17,31 +45,13 @@
|
|
|
17
45
|
"bin": {
|
|
18
46
|
"format-commit": "./lib/index.js"
|
|
19
47
|
},
|
|
20
|
-
"author": "Thomas BARKATS",
|
|
21
|
-
"keywords": [
|
|
22
|
-
"git",
|
|
23
|
-
"commit",
|
|
24
|
-
"cli",
|
|
25
|
-
"format",
|
|
26
|
-
"standardize",
|
|
27
|
-
"light",
|
|
28
|
-
"minimalist"
|
|
29
|
-
],
|
|
30
|
-
"license": "ISC",
|
|
31
48
|
"dependencies": {
|
|
32
|
-
"commander": "^
|
|
49
|
+
"commander": "^14.0.0",
|
|
33
50
|
"kleur": "^4.1.4",
|
|
34
51
|
"prompts": "^2.4.2"
|
|
35
52
|
},
|
|
36
53
|
"devDependencies": {
|
|
37
|
-
"eslint": "^
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"type": "git",
|
|
41
|
-
"url": "git+https://github.com/sendups/format-commit.git"
|
|
42
|
-
},
|
|
43
|
-
"bugs": {
|
|
44
|
-
"url": "https://github.com/sendups/format-commit/issues"
|
|
45
|
-
},
|
|
46
|
-
"homepage": "https://github.com/sendups/format-commit#readme"
|
|
54
|
+
"@eslint/js": "^9.27.0",
|
|
55
|
+
"eslint": "^9.27.0"
|
|
56
|
+
}
|
|
47
57
|
}
|