Skip to content

Commit 9f2fbd1

Browse files
committed
Initial documentation
1 parent 2281ff1 commit 9f2fbd1

File tree

3 files changed

+103
-59
lines changed

3 files changed

+103
-59
lines changed

README.md

Lines changed: 101 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,146 @@
1-
# TSDX User Guide
1+
<h1 align="center">git-notify</h1>
2+
<p align="center">
3+
<strong>Communicate important updates to your team via git commit messages</strong>
4+
<br><br>
25

3-
Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s here and how to use it.
6+
![Demo](docs/demo.gif)
47

5-
> This TSDX setup is meant for developing libraries (not apps!) that can be published to NPM. If you’re looking to build a Node app, you could use `ts-node-dev`, plain `ts-node`, or simple `tsc`.
8+
## What is git-notify?
69

7-
> If you’re new to TypeScript, checkout [this handy cheatsheet](https://devhints.io/typescript)
10+
I've often ran into a situation where I'd like to communicate a piece of information.
811

9-
## Commands
12+
## Getting started
1013

11-
TSDX scaffolds your new library inside `/src`.
12-
13-
To run TSDX, use:
14+
Install the git-notify package as a devDependency to your project:
1415

1516
```bash
16-
npm start # or yarn start
17+
# using npm
18+
npm install --save-dev git-notify
19+
20+
# using yarn
21+
yarn add -D git-notify
1722
```
1823

19-
This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`.
24+
You'll need to install [git hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to run `git-notify` automatically when other developers pull commits that contain git messages.
2025

21-
To do a one-off build, use `npm run build` or `yarn build`.
26+
Below we show how to install them with the excellent [husky](https://github.com/typicode/husky) node library. For other approaches, see the [Git Hooks](#git-hooks) section.
2227

23-
To run tests, use `npm test` or `yarn test`.
28+
### Installing hooks with husky
29+
30+
```
31+
# using npm
32+
npm install --save-dev husky@4
33+
34+
# using yarn
35+
yarn add -D husky@4
36+
```
37+
38+
Configure `git-notify` hooks by adding the following `husky` entries to your `package.json`:
39+
40+
```json
41+
{
42+
//...snip
43+
"husky": {
44+
"hooks": {
45+
"post-merge": "git-notify merge $HUSKY_GIT_PARAMS",
46+
"post-rewrite": "git-notify rewrite $HUSKY_GIT_PARAMS",
47+
"post-checkout": "git-notify checkout $HUSKY_GIT_PARAMS"
48+
}
49+
}
50+
}
51+
```
52+
53+
**Note:** The above instructions below are for [husky v4.x](https://github.com/typicode/husky/tree/master). Husky v5 changes how hooks are configured, as well changes its licensing terms to be free only to other open source projects. See [husky's own documentation](https://dev.to/typicode/what-s-new-in-husky-5-32g5) for how to configure hooks in their latest version.
2454

2555
## Configuration
2656

27-
Code quality is set up for you with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.
57+
- `--prefix "\@team:"`
58+
- Change the prefix `git-notify` looks for in git commit messages
59+
- You'll need to take care of escaping any special characters that may be interpreted by your shell, `!`, `@`, etc...
60+
- Default: `git-notifier:`
61+
- `--color "ff6f6f"`
62+
- Change the color of the banner
63+
- This can be one of the [`chalk` preset colors](https://www.npmjs.com/package/chalk#colors) or a HEX value. If using HEX value, you can either include or omit the leading `#` character.
64+
- `--simple`
65+
- Instead of a fancy banner, displays a simple text message
2866

29-
### Jest
67+
### All parameters
3068

31-
Jest tests are set up to run with `npm test` or `yarn test`.
69+
Run `npx git-notify --help` for an up to date list of parameters:
3270

33-
### Bundle Analysis
71+
```sh
72+
npx git-notify --help
3473

35-
[`size-limit`](https://github.com/ai/size-limit) is set up to calculate the real cost of your library with `npm run size` and visualize the bundle with `npm run analyze`.
74+
Usage
75+
$ git-notify <method> [options] $GIT_PARAMS
3676

37-
#### Setup Files
77+
Methods
78+
since <commit> show all notifications since commit
79+
merge run on git pull/merge
80+
rewrite run on git rebase
81+
checkout run on git checkout/switch
3882

39-
This is the folder structure we set up for you:
83+
Options
84+
--prefix, -p prefix to look for in commit messages (default: "git-notify:")
85+
--simple, -s show a plain, unboxed notification
86+
--color, -c color of displayed notification
4087

41-
```txt
42-
/src
43-
index.tsx # EDIT THIS
44-
/test
45-
blah.test.tsx # EDIT THIS
46-
.gitignore
47-
package.json
48-
README.md # EDIT THIS
49-
tsconfig.json
88+
Examples
89+
$ git-notify since HEAD~5
90+
$ git-notify checkout $GIT_PARAMS
5091
```
5192

52-
### Rollup
93+
## Git Hooks
5394

54-
TSDX uses [Rollup](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details.
95+
### Installing with husky
5596

56-
### TypeScript
97+
See [Installing hooks with husky](#installing-hooks-with-husky) in the Getting Started section.
5798

58-
`tsconfig.json` is set up to interpret `dom` and `esnext` types, as well as `react` for `jsx`. Adjust according to your needs.
99+
### Installing hooks by any other means
59100

60-
## Continuous Integration
101+
`git-notify` is agnostic to however you want to install your git hooks.
61102

62-
### GitHub Actions
103+
The hooks you need to configure are:
63104

64-
Two actions are added by default:
105+
- **post-merge** (runs on `git pull` and `git merge`)
106+
- `npx git-notify merge $GIT_PARAMS`
107+
- **post-rewrite** (runs on `git rebase`)
108+
- `npx git-notify rewrite $GIT_PARAMS`
109+
- **post-checkout** (runs on `git checkout` -- optional, but useful)
110+
- `npx git-notify checkout $GIT_PARAMS`
65111

66-
- `main` which installs deps w/ cache, lints, tests, and builds on all pushes against a Node and OS matrix
67-
- `size` which comments cost comparison of your library on every pull request using [`size-limit`](https://github.com/ai/size-limit)
112+
At the time of writing, `git-notify checkout` is the only hook that uses the arguments (`$GIT_PARAMS`) passed to the git hook, but ideally you should always pass the arguments to `git-notify`, in case we'll need to use them in a later version.
68113

69-
## Optimizations
114+
See [githooks.com](https://githooks.com/) for more resources on the topic. Documentation for different approaches are welcome!
70115

71-
Please see the main `tsdx` [optimizations docs](https://github.com/palmerhq/tsdx#optimizations). In particular, know that you can take advantage of development-only optimizations:
116+
### Installing git-notify without npm
72117

73-
```js
74-
// ./types/index.d.ts
75-
declare var __DEV__: boolean;
118+
At this time, `git-notify` is a node-based project. While I recognize it could be useful in other types of projects (ruby, python, rust, etc...), cross-platform scripting sucks, and this project is not interested in solving those problems at this time.
76119

77-
// inside your code...
78-
if (__DEV__) {
79-
console.log('foo');
80-
}
81-
```
120+
If you like this idea, feel free to steal it and implement your own version for other toolsets!
121+
122+
## Configuration
82123

83-
You can also choose to install and use [invariant](https://github.com/palmerhq/tsdx#invariant) and [warning](https://github.com/palmerhq/tsdx#warning) functions.
124+
## Contributing
84125

85-
## Module Formats
126+
This project is open to contributions. For anything that would radically change the nature of the project or increase its maintenance burden, please open an issue first to discuss.
86127

87-
CJS, ESModules, and UMD module formats are supported.
128+
### Local development
88129

89-
The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.
130+
This project is written in TypeScript and scaffolded using [tsdx](https://github.com/formium/tsdx).
90131

91-
## Named Exports
132+
To run TSDX, use:
92133

93-
Per Palmer Group guidelines, [always use named exports.](https://github.com/palmerhq/typescript#exports) Code split inside your React app instead of your React library.
134+
```bash
135+
yarn start
136+
```
94137

95-
## Including Styles
138+
This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`.
96139

97-
There are many ways to ship styles, including with CSS-in-JS. TSDX has no opinion on this, configure how you like.
140+
To do a one-off build, use `npm run build` or `yarn build`.
98141

99-
For vanilla CSS, you can include it at the root directory and add it to the `files` section in your `package.json`, so that it can be imported separately by your users and run through their bundler's loader.
142+
To run tests, use `npm test` or `yarn test`.
100143

101-
## Publishing to NPM
144+
## LICENSE
102145

103-
We recommend using [np](https://github.com/sindresorhus/np).
146+
[MIT](LICENSE)

docs/demo.gif

167 KB
Loading

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ const cli = meow(
3131
3232
Examples
3333
$ git-notify since HEAD~5
34-
$ git-notify checkout $GIT_PARAMS
34+
$ git-notify checkout $GIT_PARAMS --prefix "\@everyone:"
35+
$ git-notify merge $GIT_PARAMS --simple --color "\#ff6f6f"
3536
`,
3637
{
3738
flags: {

0 commit comments

Comments
 (0)