format-commit 0.2.2 → 0.3.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/README.md +34 -15
- package/lib/index.js +22 -7
- package/lib/options.json +6 -6
- package/package.json +32 -25
package/README.md
CHANGED
|
@@ -1,33 +1,52 @@
|
|
|
1
1
|
# format-commit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
🚀 Lightweight CLI for consistent commit message formatting.
|
|
4
|
+
|
|
5
|
+
Standardize your commit naming with basic rules, and guide your workflow through an automated script. No bloat, no complexity — just clean, consistent commits.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
```sh
|
|
8
|
-
|
|
10
|
+
npm i format-commit --save-dev
|
|
9
11
|
```
|
|
10
12
|
|
|
11
13
|
## Usage
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
Add to your `package.json` scripts:
|
|
16
|
+
```json
|
|
17
|
+
"scripts": {
|
|
18
|
+
"commit": "format-commit"
|
|
19
|
+
}
|
|
20
|
+
```
|
|
14
21
|
|
|
15
|
-
|
|
22
|
+
Then use:
|
|
23
|
+
```sh
|
|
24
|
+
npm run commit
|
|
25
|
+
```
|
|
16
26
|
|
|
17
|
-
|
|
27
|
+
Or install globally:
|
|
28
|
+
```sh
|
|
29
|
+
npm i -g format-commit
|
|
30
|
+
format-commit
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
On first use, format-commit will prompt you to configure your commit format and create a `commit-config.json` file.
|
|
18
34
|
|
|
19
|
-
|
|
35
|
+
To reconfigure later, run:
|
|
36
|
+
```sh
|
|
37
|
+
format-commit --config
|
|
38
|
+
```
|
|
20
39
|
|
|
21
40
|
## Configuration
|
|
22
41
|
|
|
23
42
|
| Property | Description |
|
|
24
43
|
| :------- | :---------- |
|
|
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
|
|
44
|
+
| **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` |
|
|
45
|
+
| **types** | Allowed commit types (default: `feat`, `fix`, `core`, `test`, `config`, `doc`) |
|
|
46
|
+
| **scopes** | Application scopes for commit categorization (formats 5-8 only) |
|
|
47
|
+
| **minLength** | Minimum commit title length |
|
|
48
|
+
| **maxLength** | Maximum commit title length |
|
|
49
|
+
| **changeVersion** | Version change policy:<br>`always` - All commits require version change<br>`only on release branch` - Only release branch commits require version change<br>`never` - Always prompt for version change |
|
|
50
|
+
| **releaseBranch** | Main/release branch name (used with `only on release branch`) |
|
|
51
|
+
| **showAllVersionTypes** | Show all version types or only main ones (`major`/`minor`/`patch`/`custom`) |
|
|
52
|
+
| **stageAllChanges** | Auto-stage all changes before commit |
|
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.0')
|
|
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,7 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "format-commit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0",
|
|
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",
|
|
7
31
|
"scripts": {
|
|
@@ -9,7 +33,8 @@
|
|
|
9
33
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
34
|
"lint": "eslint . --ext .js --fix",
|
|
11
35
|
"prepublishOnly": "npm run lint",
|
|
12
|
-
"preversion": "npm run lint"
|
|
36
|
+
"preversion": "npm run lint",
|
|
37
|
+
"commit": "npm run lint && npm run start"
|
|
13
38
|
},
|
|
14
39
|
"files": [
|
|
15
40
|
"lib/**/*"
|
|
@@ -17,31 +42,13 @@
|
|
|
17
42
|
"bin": {
|
|
18
43
|
"format-commit": "./lib/index.js"
|
|
19
44
|
},
|
|
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
45
|
"dependencies": {
|
|
32
|
-
"commander": "^
|
|
46
|
+
"commander": "^14.0.0",
|
|
33
47
|
"kleur": "^4.1.4",
|
|
34
48
|
"prompts": "^2.4.2"
|
|
35
49
|
},
|
|
36
50
|
"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"
|
|
51
|
+
"@eslint/js": "^9.27.0",
|
|
52
|
+
"eslint": "^9.27.0"
|
|
53
|
+
}
|
|
47
54
|
}
|