Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
negoziator committed Oct 7, 2023
0 parents commit 1a9400c
Show file tree
Hide file tree
Showing 52 changed files with 17,528 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.yml]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: negoziator
56 changes: 56 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Bug report
description: File a bug report
labels: [bug, pending triage]
body:
- type: markdown
attributes:
value: |
Thank you for taking the time to file this bug report.
- type: textarea
attributes:
label: Bug description
description: A clear and concise description of the bug.
placeholder: |
<!--
What did you do, what did you expect to happen, and what happened instead?
-->
validations:
required: true
- type: input
attributes:
label: aicommit version
description: |
Run and paste the output of:
```sh
aicommit --version
```
placeholder: v0.0.0
validations:
required: true
- type: textarea
attributes:
label: Environment
description: |
Run and paste the output of:
```sh
npx envinfo --system --binaries
```
This information is used to for reproduction and debugging.
placeholder: |
System:
OS:
CPU:
Shell:
Binaries:
Node:
npm:
render: shell
validations:
required: true
- type: checkboxes
attributes:
label: Can you contribute a fix?
description: We would love it if you can open a pull request to fix this bug!
options:
- label: I’m interested in opening a pull request for this issue.
43 changes: 43 additions & 0 deletions .github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Feature request
description: Suggest an idea for this project
labels: [feature, pending triage]
body:
- type: markdown
attributes:
value: |
Thank you for taking the time to file this feature request.
- type: textarea
attributes:
label: Feature request
description: A description of the feature you would like.
validations:
required: true
- type: textarea
attributes:
label: Why?
description: |
Describe the problem you’re tackling with this feature request.
placeholder: |
<!--
What’s the motivation behind this issue?
eg. “I’m frustrated when...”
-->
validations:
required: true
- type: textarea
attributes:
label: Alternatives
description: |
Have you considered alternative solutions? Is there a workaround?
placeholder: |
<!--
Do you have alternative proposals?
Do you have a workaround?
-->
- type: textarea
attributes:
label: Additional context
description: |
Anything else to share? Screenshots? Links?
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
Binary file added .github/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release

on:
push:
branches: [master]

jobs:
release:
name: Release
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write

steps:

- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 7
run_install: true

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm dlx semantic-release
52 changes: 52 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Test

on:
push:
branches: [master, develop]
pull_request:

jobs:
test:
name: Test
strategy:
matrix:
os: [ubuntu-latest, windows-latest]

runs-on: ${{ matrix.os }}
timeout-minutes: 10

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 7
run_install: true

- name: Type check
run: pnpm type-check

- name: Lint
run: pnpm lint

- name: Build
run: pnpm build

- name: Install tinyproxy
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install tinyproxy
tinyproxy
- name: Test
env:
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
run: |
pnpm test
pnpm --use-node-version=14.21.3 test
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# macOS
.DS_Store

# IDE
.idea

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Dependency directories
/node_modules/

# Output of 'npm pack'
*.tgz

# dotenv environment variables file
.env
.env.test

# Distribution
dist

# Eslint cache
.eslintcache
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.14.0
75 changes: 75 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Contribution Guide

## Setting up the project

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
```

## 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.


### 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
```

## 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:
```sh
./dist/cli.mjs
```

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

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`](https://github.com/privatenumber/git-publish):

Publish your current branch to a `npm/*` branch on your GitHub repository:
```sh
$ pnpm dlx git-publish

✔ Successfully published branch! Install with command:
→ npm i 'NegoZiatoR/aicommit#npm/develop'
```

> Note: The `NegoZiatoR/aicommit` will be replaced with your fork's URL.
Now, you can run the branch in your project:
```sh
$ pnpm dlx 'NegoZiatoR/aicommit#npm/develop' # same as running `npx aicommit`
```
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Lars Schou

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 1a9400c

Please sign in to comment.