Skip to content

Commit

Permalink
Use Bun, upgrade setup, publish only ESM (#722)
Browse files Browse the repository at this point in the history
* Switch to Bun as package manager

* Update GHA workflows to use Bun

* Import functions from vitest

* Update setup to match new packages

* Add verify exports job

* Update package.json

* Pass Prettier

* Pass Prettier to README

* Update code examples

* Update ci.json

* Pass Prettier

* Remove build files

* Update main and typings

* Update .gitignore

* Update package.json

* Update package.json
  • Loading branch information
sergiodxa committed Mar 21, 2024
1 parent 92d6a62 commit 9b8888b
Show file tree
Hide file tree
Showing 26 changed files with 969 additions and 25,548 deletions.
4 changes: 2 additions & 2 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"sandboxes": ["/example"],
"node": "14"
"sandboxes": ["/example"],
"node": "18"
}
54 changes: 54 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* eslint-disable unicorn/prefer-module */
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
plugins: [
"@typescript-eslint",
"import",
"jsx-a11y",
"prettier",
"promise",
"react-hooks",
"react",
"unicorn",
],
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/typescript",
"plugin:import/warnings",
"plugin:jsx-a11y/recommended",
"plugin:prettier/recommended",
"plugin:promise/recommended",
"plugin:react-hooks/recommended",
"plugin:react/recommended",
"plugin:unicorn/recommended",
],
settings: {
react: { version: "detect" },
"import/resolver": { typescript: {} },
},
rules: {
"@typescript-eslint/explicit-module-boundary-types": "off",
"no-unused-vars": "off",
"no-var": "off",
"prefer-const": "off",
"react/prop-types": "off",
"react/button-has-type": "error",
"react/function-component-definition": [
"error",
{
namedComponents: "function-declaration",
unnamedComponents: "arrow-function",
},
],
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error",
"unicorn/filename-case": "off",
"unicorn/no-null": "off",
"unicorn/prefer-node-protocol": "off",
"unicorn/prevent-abbreviations": "off",
},
};
16 changes: 8 additions & 8 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "10:00"
open-pull-requests-limit: 10
assignees:
- sergiodxa
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "10:00"
open-pull-requests-limit: 10
assignees:
- sergiodxa
42 changes: 21 additions & 21 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
changelog:
categories:
- title: New Features
labels:
- enhancement
- title: Documentation Changes
labels:
- documentation
- title: Example
labels:
- example
- title: Bug Fixes
labels:
- bug
- title: Deprecations
labels:
- deprecated
- title: Dependency Upgrades
labels:
- dependencies
- title: Other Changes
labels:
- "*"
- title: New Features
labels:
- enhancement
- title: Documentation Changes
labels:
- documentation
- title: Example
labels:
- example
- title: Bug Fixes
labels:
- bug
- title: Deprecations
labels:
- deprecated
- title: Dependency Upgrades
labels:
- dependencies
- title: Other Changes
labels:
- "*"
32 changes: 17 additions & 15 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,33 @@ on:
workflow_dispatch:
inputs:
version:
description: 'Semver type of new version (major / minor / patch)'
description: "Semver type of new version (major / minor / patch)"
required: true
type: choice
options:
- major
- minor
- patch

jobs:
bump-version:
name: Bump version
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Setup Node.js
uses: actions/setup-node@v2

- uses: oven-sh/setup-bun@v1
- run: bun install

- uses: actions/setup-node@v4
with:
node-version: '16'
cache: 'npm'
- name: Install dependencies
uses: bahmutov/npm-install@v1
- name: Setup Git
run: |
node-version: "lts/*"

- run: |
git config user.name 'Sergio Xalambrí'
git config user.email 'hello@sergiodxa.com'
- name: bump version
run: npm version ${{ github.event.inputs.version }}
- name: Push latest version
run: git push origin main --follow-tags
- run: npm version ${{ github.event.inputs.version }}
- run: git push origin main --follow-tags
78 changes: 24 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,73 +7,43 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run build

- name: Use Node LTS
uses: actions/setup-node@v2
with:
node-version: "lts/*"

- name: Install dependencies
uses: bahmutov/npm-install@v1

- name: Build
run: npm run build
exports:
name: Verify Exports
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run test:exports

typecheck:
name: Typechecker
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Use Node LTS
uses: actions/setup-node@v2
with:
node-version: "lts/*"

- name: Install dependencies
uses: bahmutov/npm-install@v1

- name: Typecheck
run: npm run typecheck
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run typecheck

test:
name: Unit and Integration Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Use Node LTS
uses: actions/setup-node@v2
with:
node-version: "lts/*"

- name: Install dependencies
uses: bahmutov/npm-install@v1

- name: Test
run: npm run test -- --coverage
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run test

lint:
name: Linter
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Use Node LTS
uses: actions/setup-node@v2
with:
node-version: "lts/*"

- name: Install dependencies
uses: bahmutov/npm-install@v1

- name: Build
run: npm run build

- name: Lint
run: npm run lint
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run lint
12 changes: 6 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ jobs:
name: "Publish to npm"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run build
- run: bun run test:exports

- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: "lts/*"
registry-url: https://registry.npmjs.org/

- run: npm install

- run: npm run build

- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,5 @@ dist

example/yarn.lock
example/build

build
26 changes: 13 additions & 13 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Expand Down

0 comments on commit 9b8888b

Please sign in to comment.