Skip to content

Commit f07ac60

Browse files
committed
docs: update 2 files and create 2 files
1 parent d4e0991 commit f07ac60

File tree

4 files changed

+148
-24
lines changed

4 files changed

+148
-24
lines changed

docs/README.md

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,11 @@ This project serves to prepare a smart commit message for you, to make your deve
88
- [Quickstart](quickstart.md)
99
- [About](about.md)
1010
- [Features](features.md)
11-
- What it can do, upcoming features, and how it works
11+
- What it can do, upcoming features, and how it works,
1212
- [User manual](manual/)
13-
- How to install and use the installed extension.
13+
- How to install and use the extension.
14+
- [CLI](cli.md)
15+
- How install and run as a CLI tool only.
1416
- [Development](development/)
1517
- Guide for developers to set up and run locally.
1618
- Useful for testing your changes before contributing a PR.
17-
18-
<!--
19-
20-
The docs are split into two features:
21-
22-
- [Extension](extension.md)
23-
- [Terminal hook](terminal-hook.md)
24-
25-
Part ideas:
26-
27-
- A shell script in a repo
28-
- References a concatenated JS script from this repo (just the text handling and not the full extension), which is in a bin directory.
29-
30-
-->

docs/cli.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# CLI
2+
> How to use AutoCommitMsg in the terminal instead of as an extension
3+
4+
See steps below to setup and run the tool in the CLI. VS Code is not needed.
5+
6+
For development, see [CLI Development](development/cli.md).
7+
8+
## Requirements
9+
10+
- Node (see version in [package.json](/package.json))
11+
- Git
12+
13+
_This should work on Windows too but has not been tested yet._
14+
15+
## Setup
16+
17+
### Clone the repo
18+
19+
```sh
20+
$ git clone git@github.com:MichaelCurrin/auto-commit-msg.git
21+
$ cd auto-commit-msg
22+
```
23+
24+
### Install dependencies
25+
26+
```sh
27+
$ npm ci
28+
```
29+
30+
### Build and link the CLI tools
31+
32+
```sh
33+
$ npm run cli
34+
```
35+
36+
Verify installation:
37+
38+
```sh
39+
$ acm -h
40+
$ gacm -h
41+
```
42+
43+
## Usage
44+
45+
Use the `-h` or `--help` flags with any of these to avoid making changes.
46+
47+
<!--
48+
TODO consolidate to one command with commit flag or dry run?
49+
TODO pass params like file names through for either command. For message and committing. The downside is for new files - even if git commit would pick them up by name, diff-index would not. You can also use whatever IDE to stage and still generate+commit with the CLI.
50+
TODO -c not just --cached but pass through as --cached.
51+
And use default behavior for if there is staged then use that for commit message - make it smart.
52+
-->
53+
54+
### Generate a message from changes and commit
55+
56+
This is the **main** command you should use.
57+
58+
Note this actually **commit**, so if you want to experiment with commit output **without** committing, use the command below instead.
59+
60+
No flags are needed.
61+
62+
```sh
63+
$ gacm
64+
```
65+
66+
### Check Git changes and generate commit message
67+
68+
This will **not** commit.
69+
70+
No flags are needed.
71+
72+
```sh
73+
$ acm
74+
```
75+
76+
### Generate a message from staged changes
77+
78+
This is a simpler command which does not interact with Git, intended for integrating with the Bash shell.
79+
80+
See [shell/acm.sh](/shell/acm.sh) if you want to use that script or write your own shell script. That relies on using this executable Node script
81+
82+
```sh
83+
$ auto_commit_message_generate "$CHANGES"
84+
```
85+
86+
### Usage tips
87+
88+
The behavior depends on how Git treats files, so you should know these points:
89+
90+
- The commands will pick up on staged changes and certain unstaged changes (modified and deleted, but not created as they are untracked).
91+
- If you want to handle created files, make sure to stage them first.
92+
- If you want to target only select changes for smaller commit, then stage stages and use the `--cached` flag to ignored unstaged changes.
93+
94+
## Uninstall the linked CLI (optional)
95+
96+
If you get permission denied error, you can do this and then go back to the install step.
97+
98+
```sh
99+
$ npm unlink -g auto-commit-msg
100+
```

docs/development/cli.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# CLI Development
2+
> Maintaining code around the CLI tool
3+
4+
The code is in [src/cli/](/src/cli). The CLI commands are built using steps set in [package.json](/package.json) - see the `cli` command and `bin` section.
5+
6+
7+
8+
## Run directly
9+
10+
```sh
11+
$ npx ts-node src/cli/diffIndexGenerate.ts
12+
```
13+
14+
15+
## Package as a binary
16+
17+
To send to someone so they can use it without having Node installed or running a build step on their machine.
18+
19+
```sh
20+
$ npx --yes pkg out/cli/diffIndexGenerateCommit.js -t node18-macos
21+
```
22+
23+
## Troubleshooting
24+
25+
On macOS, installed here as a symlink pointing to the `.js` file in the repo:
26+
27+
```
28+
/opt/homebrew/bin/acm
29+
```
30+
31+
If you get permissions issues, it is because the `.js` file was rebuilt and with standard permissions and needs to be linked again.
32+
33+
```sh
34+
$ npm run cli
35+
```
36+
37+
Check:
38+
39+
```sh
40+
ls -l $(realpath /opt/homebrew/bin/acm)
41+
```
42+
43+
See [package.json](/package.json). Supposedly you should be able to leave out the project name when running `npm link` via an `npm run ...` command but I found this causes issues, so decided to always use the full name in the configuration. And to _always_ unlink then link in one go because of permissions issues.

docs/features.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,7 @@ A roadmap of features and whether done or not.
1616
- Note that **new** files (including when doing a rename) should **always** be staged so that the extension can pick them up and so git can see that two paths for a renamed file are the same file.
1717
- [x] Generate a single-line commit message for a file to be committed, using action verbs (e.g. `Create`, `Update`, `Delete`)
1818
- [x] Handle changes from a single changed file.
19-
- [ ] Handle changes from two or more files.
20-
- [x] As a list of the same nature e.g. `update foo.txt and fizz/bar.txt`, `feat: create foo.txt, fizz/bar.txt and buzz.js` (including prefix) and `Various changes to foo.txt and fizz/bar.txt` (for one updated and one new file). See [#29](https://github.com/MichaelCurrin/auto-commit-msg/pull/29).
21-
- [x] As a count. e.g. `update 3 files`. See [#38](https://github.com/MichaelCurrin/auto-commit-msg/issues/38).
22-
- [ ] As different verb for each change `create foo.txt and delete bar.txt`. See [#37](https://github.com/MichaelCurrin/auto-commit-msg/issues/37) and See [#52](https://github.com/MichaelCurrin/auto-commit-msg/issues/52).
23-
- [ ] As a count in a directory. `update 3 files in foo`
24-
- [ ] As a count with a conventional commit message. See [#51](https://github.com/MichaelCurrin/auto-commit-msg/issues/51).
25-
- [ ] As a count with a label. e.g. `update 3 config files`. See [#13](https://github.com/MichaelCurrin/auto-commit-msg/issues/13).
26-
- [ ] As count that uses the old message. See [#55](https://github.com/MichaelCurrin/auto-commit-msg/issues/55)
19+
- [x] Handle changes from two or more files.
2720
- [x] Support using multiple repos in one VS Code window.
2821
- [x] Keep user-entered value as a prefix e.g. Keep `docs:` (or ticket number) so message becomes `docs: Update README.md`
2922
- [x] Use conventional commits e.g. `chore: Update package.json`

0 commit comments

Comments
 (0)