Skip to content

Commit

Permalink
πŸŽ‰ Setup the project (#2)
Browse files Browse the repository at this point in the history
* πŸŽ‰ Setup the project

* 🚚 Rename LICENSE.txt

* πŸ“ Update GitHub Actions badges in README.md

* πŸ”§ Enforce modern tsconfig.json

* 🦺 Use `readonly`

* πŸ”§ Update permissions in pnpm-publish.yaml and pnpm-version-patch.yaml workflows
  • Loading branch information
NatoBoram authored Mar 25, 2024
1 parent d9719c3 commit 39be88f
Show file tree
Hide file tree
Showing 30 changed files with 3,551 additions and 2,836 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist/
docs/
node_modules/
package-lock.json
pnpm-lock.yaml
43 changes: 43 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
root: true
env:
browser: true
es2021: true
node: true
extends:
- plugin:@typescript-eslint/strict-type-checked
- plugin:@typescript-eslint/stylistic-type-checked
- prettier
parser: "@typescript-eslint/parser"
parserOptions:
ecmaVersion: latest
sourceType: module
project: "./tsconfig.eslint.json"
plugins:
- "@typescript-eslint"
rules:
"@typescript-eslint/class-methods-use-this": error
"@typescript-eslint/consistent-type-exports": error
"@typescript-eslint/consistent-type-imports": error
"@typescript-eslint/default-param-last": error
"@typescript-eslint/explicit-member-accessibility":
- error
- accessibility: no-public
"@typescript-eslint/method-signature-style": error
"@typescript-eslint/no-import-type-side-effects": error
"@typescript-eslint/no-unnecessary-qualifier": error
"@typescript-eslint/no-useless-empty-export": error
"@typescript-eslint/prefer-nullish-coalescing":
- error
- ignorePrimitives: true
"@typescript-eslint/prefer-readonly": error
"@typescript-eslint/prefer-regexp-exec": error
"@typescript-eslint/promise-function-async":
- error
- checkArrowFunctions: false
"@typescript-eslint/require-array-sort-compare": error
"@typescript-eslint/return-await": error
"@typescript-eslint/sort-type-constituents": error

func-style:
- error
- declaration
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @coderabbitai/typescript-reviewers
1 change: 1 addition & 0 deletions .github/authorized_keys
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
41898282+github-actions[bot]@users.noreply.github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKOzgFi8S4xZHCSjGi3u0T2OZYvefkFu8px+bLncFhq8 41898282+github-actions[bot]@users.noreply.github.com
45 changes: 45 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: monthly
timezone: America/Toronto
commit-message:
prefix: "⬆️ "
groups:
patch-development:
dependency-type: development
update-types:
- patch
patch-production:
dependency-type: production
update-types:
- patch

eslint:
patterns:
- "*eslint*"
prettier:
patterns:
- "*prettier*"
openai:
patterns:
- "*openai*"
- "*tiktoken*"
vite:
patterns:
- vite
- vitest
typescript:
patterns:
- "*typescript*"
- tslib

- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
timezone: America/Toronto
commit-message:
prefix: "⬆️ "
20 changes: 0 additions & 20 deletions .github/workflows/ci.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/github-pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: GitHub Pages

on:
push:
branches: main

jobs:
build_pages:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: latest
- uses: actions/setup-node@v3
with:
node-version: 21
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm run docs
- uses: actions/upload-pages-artifact@v1
with:
path: docs

deploy_pages:
needs: build_pages

permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest

steps:
- id: deployment
uses: actions/deploy-pages@v1
25 changes: 25 additions & 0 deletions .github/workflows/node.js.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Node.js CI

on:
push:
branches: main
pull_request:
branches: main

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: latest
- uses: actions/setup-node@v3
with:
node-version: 21
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm run build --noEmit
- run: pnpm run lint
- run: pnpm run test
55 changes: 55 additions & 0 deletions .github/workflows/pnpm-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Node.js Publish

on:
push:
tags:
- v*

jobs:
publish:
runs-on: ubuntu-latest

permissions:
contents: write
id-token: write
packages: write

steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: latest
- uses: actions/setup-node@v3
with:
cache: pnpm
node-version: 21
- run: pnpm install
- run: pnpm build

- uses: actions/setup-node@v4
with:
registry-url: https://npm.pkg.github.com
scope: "@coderabbitai"
- run: pnpm publish --access public --no-git-checks --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org
scope: "@coderabbitai"
- run: pnpm publish --access public --no-git-checks --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.CODERABBIT_NPMTOKEN }}

- run: pnpm pack --pack-gzip-level 9
- name: Sign
run: |
eval `ssh-agent -s`
ssh-add - <<< '${{ secrets.DEPLOY_KEY_PRIVATE }}'
echo '${{ vars.DEPLOY_KEY_PUBLIC }}' > '${{ runner.temp }}/DEPLOY_KEY_PUBLIC.pub'
ssh-keygen -Y sign -f '${{ runner.temp }}/DEPLOY_KEY_PUBLIC.pub' -n file coderabbitai-openai-chat-tokens-*.tgz
ssh-keygen -Y verify -f ./.github/authorized_keys -I '41898282+github-actions[bot]@users.noreply.github.com' -n file -s coderabbitai-openai-chat-tokens-*.tgz.sig < coderabbitai-openai-chat-tokens-*.tgz
- run: gh release upload ${{ github.ref_name }} coderabbitai-openai-chat-tokens-*.tgz coderabbitai-openai-chat-tokens-*.tgz.sig
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44 changes: 44 additions & 0 deletions .github/workflows/pnpm-version-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Node.js Patch

on: workflow_dispatch

jobs:
patch:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.DEPLOY_KEY_PRIVATE }}
- uses: pnpm/action-setup@v2
with:
version: latest
- uses: actions/setup-node@v3
with:
cache: pnpm
node-version: 21
- name: Configure Git, patch, release and push
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git config commit.gpgsign true
git config gpg.format ssh
git config user.signingkey 'key::${{ vars.DEPLOY_KEY_PUBLIC }}'
eval `ssh-agent -s`
ssh-add - <<< '${{ secrets.DEPLOY_KEY_PRIVATE }}'
VERSION=$(pnpm version patch --no-git-tag-version)
git commit --all --message "πŸ”– $VERSION"
git tag --annotate --message "πŸ”– $VERSION" --sign $VERSION
git push
git push --tags
gh release create $VERSION --generate-notes --title $VERSION --verify-tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 0 additions & 21 deletions .github/workflows/publish.yml

This file was deleted.

Loading

0 comments on commit 39be88f

Please sign in to comment.