Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor package #14

Merged
merged 24 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 0 additions & 5 deletions .env.example

This file was deleted.

2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

14 changes: 5 additions & 9 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,21 @@
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": [
"@typescript-eslint"
],
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/consistent-type-definitions": [
"error",
"type"
]
"@typescript-eslint/consistent-type-definitions": ["error", "type"]
},
"env": {
"browser": true,
"es2021": true
}
}
}
64 changes: 64 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Compile and publish package

on:
release:
types: [published]

jobs:
deploy:
permissions:
packages: write
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Enable Corepack before setting up Node
run: corepack enable

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: yarn

- name: Compile Typescript
run: yarn build

- name: Update package.json version
run: |
release_version=${GITHUB_REF_NAME#v}
jq ".version = \"$release_version\"" package.json > package.json.tmp
mv package.json.tmp package.json

- name: Commit updated package.json
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add package.json
git commit -m "chore: sync version with release $release_version"
git push

- name: Validate release version
run: |
release_version=${GITHUB_REF_NAME#v}
current_version=$(jq -r '.version' package.json)
if [ "$release_version" != "$current_version" ]; then
echo "Version mismatch: release tag ($release_version) does not match package.json ($current_version)."
exit 1
fi

- name: Setup .yarnrc.yml
run: |
yarn config set npmAlwaysAuth true
yarn config set npmAuthToken $NPM_AUTH_TOKEN
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

- name: Publish to NPM Registry
run: yarn npm publish --access public
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ jobs:
node-version: '18'

- name: Install dependencies
run: npm install
run: yarn

- name: Linting Typescript
run: npm run lint
run: yarn lint

- name: Compile Typescript
run: npm run build
run: yarn build

- name: Run tests
run: npm run test
run: yarn test
34 changes: 24 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
.env
node_modules
tmp
logs
*.log
npm-debug.log*
.npm
.eslintcache
dist
.DS_Store
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Swap the comments on the following lines if you don't wish to use zero-installs
# Documentation here: https://yarnpkg.com/features/zero-installs
!.yarn/cache
#.pnp.*

# Compiled typescript
dist/*

.DS_Store

# local files
*.local.*

# Jetbrains ide
.idea

.env
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/src/
/.vscode/
/.yarn/
.todo/
*.env
*.example
Loading
Loading