chore: improve contribution guide

This commit is contained in:
Hiroki Osame
2023-03-10 22:54:27 +09:00
parent afad8210fc
commit bacda17e5a
4 changed files with 56 additions and 12 deletions

View File

@@ -1,29 +1,29 @@
# Contributing guide
# Contribution Guide
## Setting up the project
Use nvm to set the appropriate Node.js version:
```
Use [nvm](https://nvm.sh) to use the appropriate Node.js version from `.nvmrc`:
```sh
nvm i
```
Install the dependencies using pnpm:
```
```sh
pnpm i
```
## Producing a build
## Building the project
Run the `build` script:
```
```sh
pnpm build
```
The package is bundled using [pkgroll](https://github.com/privatenumber/pkgroll) (Rollup). It infers the entry-points from `package.json` so there are no build configurations.
### Watch mode
### Development (watch) mode
During development, you can use the watch flag (`--watch, -w`) to automatically rebuild the package on file changes:
```
```sh
pnpm build -w
```
@@ -31,11 +31,42 @@ pnpm build -w
Since pkgroll knows the entry-point is a binary (being in `package.json#bin`), it automatically adds the Node.js hashbang to the top of the file, and chmods it so it's executable.
You can run the distribution file in any directory:
```
```sh
./dist/cli.mjs
```
Or in non UNIX environments, you can use Node.js to run the file:
```
Or in non-UNIX environments, you can use Node.js to run the file:
```sh
node ./dist/cli.mjs
```
## Testing
Testing requires passing in `OPENAI_KEY` as an environment variable:
```sh
OPENAI_KEY=<your OPENAI key> pnpm test
```
You can still run tests that don't require `OPENAI_KEY` but will not test the main functionality:
```
pnpm test
```
## Using & testing your changes
You can publish the package to a GitHub branch using [`git-publish`](https://github.com/privatenumber/git-publish):
Publish your current branch to a GitHub branch:
```sh
$ npx git-publish
✔ Successfully published branch! Install with command:
→ npm i 'Nutlope/aicommits#npm/develop'
```
Then you can use the output to test the changes:
```sh
$ npx 'Nutlope/aicommits#npm/develop' # same as running `npx aicommits`
```

View File

@@ -119,3 +119,8 @@ Video coming soon where I rebuild it from scratch to show you how to easily buil
- **Hiroki Osame**: [@privatenumber](https://github.com/privatenumber) [<img src="https://img.shields.io/twitter/follow/privatenumbr?style=flat&label=privatenumbr&logo=twitter&color=0bf&logoColor=fff" align="center">](https://twitter.com/privatenumbr)
## Contributing
If you want to help fix a bug or implement a feature in [Issues](https://github.com/Nutlope/aicommits/issues), checkout the [Contribution Guide](CONTRIBUTING.md) to learn how to setup and test the project.

View File

@@ -21,7 +21,7 @@
"lint": "eslint --cache .",
"type-check": "tsc",
"test": "tsx tests",
"prepack": "pnpm build"
"prepack": "pnpm build && clean-pkg-json"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"
@@ -38,6 +38,7 @@
"@types/ini": "^1.3.31",
"@types/inquirer": "^9.0.3",
"@types/node": "^18.14.2",
"clean-pkg-json": "^1.2.0",
"cleye": "^1.3.2",
"eslint": "^8.35.0",
"execa": "^7.0.0",

7
pnpm-lock.yaml generated
View File

@@ -12,6 +12,7 @@ specifiers:
'@types/ini': ^1.3.31
'@types/inquirer': ^9.0.3
'@types/node': ^18.14.2
clean-pkg-json: ^1.2.0
cleye: ^1.3.2
eslint: ^8.35.0
execa: ^7.0.0
@@ -35,6 +36,7 @@ devDependencies:
'@types/ini': 1.3.31
'@types/inquirer': 9.0.3
'@types/node': 18.14.2
clean-pkg-json: 1.2.0
cleye: 1.3.2
eslint: 8.35.0
execa: 7.0.0
@@ -998,6 +1000,11 @@ packages:
engines: {node: '>=8'}
dev: true
/clean-pkg-json/1.2.0:
resolution: {integrity: sha512-QHBWWOtpSCv5nfMFKwyxn4WMvkYE0msxj5xiqejYGqYepWVrK7O/om1Vn6nSl/WPtYn8ge9YmSCbTi1Hp8k+Hg==}
hasBin: true
dev: true
/clean-regexp/1.0.0:
resolution: {integrity: sha512-GfisEZEJvzKrmGWkvfhgzcz/BllN1USeqD2V6tg14OAOgaCD2Z/PUEuxnAZ/nPvmaHRG7a8y77p1T/IRQ4D1Hw==}
engines: {node: '>=4'}