Skip to content

Latest commit

 

History

History
75 lines (53 loc) · 1.87 KB

CONTRIBUTING.md

File metadata and controls

75 lines (53 loc) · 1.87 KB

Contribution Guide

Setting up the project

Use nvm to use the appropriate Node.js version from .nvmrc:

nvm i

Install the dependencies using pnpm:

pnpm i

Building the project

Run the build script:

pnpm build

The package is bundled using pkgroll (Rollup). It infers the entry-points from package.json so there are no build configurations.

Development (watch) mode

During development, you can use the watch flag (--watch, -w) to automatically rebuild the package on file changes:

pnpm build -w

Running the package locally

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:

./dist/cli.mjs

Or in non-UNIX environments, you can use Node.js to run the file:

node ./dist/cli.mjs

Testing

Testing requires passing in OPENAI_KEY as an environment variable:

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

Let's say you made some changes in a fork/branch and you want to test it in a project. You can publish the package to a GitHub branch using git-publish:

Publish your current branch to a npm/* branch on your GitHub repository:

$ pnpm dlx git-publish

✔ Successfully published branch! Install with command:
  → npm i 'Nutlope/aicommits#npm/develop'

Note: The Nutlope/aicommits will be replaced with your fork's URL.

Now, you can run the branch in your project:

$ pnpm dlx 'Nutlope/aicommits#npm/develop' # same as running `npx aicommits`