Skip to content

Commit

Permalink
migrating to turborepo & tsup continued
Browse files Browse the repository at this point in the history
  • Loading branch information
onderonur committed Aug 17, 2024
1 parent 1708584 commit ba6ce6e
Show file tree
Hide file tree
Showing 54 changed files with 3,487 additions and 1,869 deletions.
5 changes: 3 additions & 2 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"projectOwner": "onderonur",
"repoType": "github",
"repoHost": "https://github.com",
"files": ["README.md"],
"files": ["./packages/react-infinite-scroll-hook/README.md"],
"imageSize": 100,
"commit": true,
"commitConvention": "none",
Expand All @@ -30,5 +30,6 @@
"contributions": ["example"]
}
],
"contributorsPerLine": 7
"contributorsPerLine": 7,
"linkToUsage": true
}
10 changes: 0 additions & 10 deletions .eslintrc.js

This file was deleted.

68 changes: 68 additions & 0 deletions .github/workflows/nextjs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# https://github.com/actions/starter-workflows/blob/main/pages/nextjs.yml
# Sample workflow for building and deploying a Next.js site to GitHub Pages
#
# To get started with Next.js see: https://nextjs.org/docs/getting-started
#
name: Deploy Next.js site to Pages

on:
# Runs when `Quality` workflow gets completed on `main` branch
workflow_run:
branches: ['main']
workflows: ['Quality']
types:
- completed
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: 'pages'
cancel-in-progress: false

jobs:
# Build job
build:
# Since `workflow_run` only has 3 activity types (`completed`, `requested` and `in_progress`),
# even if `Quality` workflow gets completed by failing, this workflow starts to run.
# To prevent this, we add a condition here.
# https://github.com/orgs/community/discussions/26238#discussioncomment-3250901
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Install
uses: ./.github/composite-actions/install
- name: Build with Next.js
run: npm run build -- --filter=demo
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./apps/demo/out

# Deployment job
deploy:
# Since `workflow_run` only has 3 activity types (`completed`, `requested` and `in_progress`),
# even if `Quality` workflow gets completed by failing, this workflow starts to run.
# To prevent this, we add a condition here.
# https://github.com/orgs/community/discussions/26238#discussioncomment-3250901
if: ${{ github.event.workflow_run.conclusion == 'success' }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
22 changes: 8 additions & 14 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: Quality

on:
push:
branches:
# TODO: This will be replaced with `main` later.
- monorepo
branches: ['main']
pull_request:
branches: ['main']
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# To cancel previous workflow when a new one is triggered.
concurrency:
Expand All @@ -18,48 +20,40 @@ jobs:
steps:
- name: Check out
uses: actions/checkout@v4

- name: Install
uses: ./.github/composite-actions/install

- name: Run format check
run: npm run format
run: npm run format:check

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4

- name: Install
uses: ./.github/composite-actions/install

- name: Run lint check
run: npm run lint
run: npm run lint:check

typecheck:
name: Typecheck
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4

- name: Install
uses: ./.github/composite-actions/install

- name: Run type check
run: npm run typecheck
run: npm run types:check

build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4

- name: Install
uses: ./.github/composite-actions/install

- name: Run build
run: npm run build
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ out/
build
dist


# Debug
npm-debug.log*
yarn-debug.log*
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
npx lint-staged
npm run typecheck
npm run types:check
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
136 changes: 136 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Contributing

This repository is created by using [Turborepo](https://turbo.build/repo). To understand the repository structure better, please check its [documentation](https://turbo.build/repo/docs).

## Local Development

After cloning the repository, we need to install the dependencies.

```bash
npm install
```

To start the demo Next.js app which uses the local version of `react-infinite-scroll-hook`, we can run `dev` script.

```bash
npm run dev
```

After this, we can open `http://localhost:3000` in the browser to display the app.

## Code Quality Checks

We use automated checks by using [ESLint](https://eslint.org/), [Prettier](https://prettier.io/) and [TypeScript](https://www.typescriptlang.org/) to provide the highest quality code as it can be.

All checks are run automatically before committing by using [husky](https://github.com/typicode/husky) and [lint-staged](https://github.com/lint-staged/lint-staged).

The checks can be run manually by running the below command too.

```bash
npm run codequality:check
```

And the same checks can be run also by enabling fixes for auto-fixable issues.

```bash
npm run codequality:fix
```

`codequality` scripts run underlying ESLint (`lint`), Prettier (`format`) and TypeScript (`types`) scripts. To run these tools individually, we can also use the below scripts.

```bash
# ESLint checks
npm run lint:check
# ESLint fixes
npm run lint:fix

# Prettier checks
npm run format:check
# Prettier fixes
npm run format:fix

# TypeScript checks
npm run types:check
# There is no auto-fix script for TypeScript.
```

## Updating Dependencies

We use `npm-check-updates` package to automatically check if there are newer versions of our dependencies.

To run it, we can use the below command. It starts an interactive CLI to check the dependencies of all the apps and packages, including the root dependencies.

```bash
npm run updates:check
```

## Adding Contributors

[all-contributors-cli](https://github.com/all-contributors/cli) is used for maintaining the contributors of this repository.

To add a new contributor, we can run the below command and follow its instructions.

```bash
npm run contributors:add
```

## Prepublish Checks

To be sure everything is OK with the latest changes, we can use [publint](https://publint.dev/) and [Are the Types Wrong](https://github.com/arethetypeswrong/arethetypeswrong.github.io).

Firstly, we need to build the bundle with the latest changes.

```bash
npm run build:bundle
```

This command will create (or update) the `packages/react-infinite-scroll-hook/dist` folder, which will be used by the clients of this package.

To be sure the output is OK for ESM and CJS clients, we can run the below commands and check their outputs.

```bash
# For `publint`
npm run publint:check -w react-infinite-scroll-hook

# For `Are the Types Wrong`
npm run attw:check -w react-infinite-scroll-hook
```

To see the content of the package which can be uploaded to [npm](https://www.npmjs.com/) can be seen by using the below command. It will create a tarball from `react-infinite-scroll-hook` package.

```bash
npm pack -w react-infinite-scroll-hook
```

Or the below command can be used to only check the tarball contents without creating it.

```bash
npm pack --dry-run -w react-infinite-scroll-hook
```

Lastly, we can run the below command to auto correct common errors in `package.json` of the package to be published. `npm publish` command already does these auto-fixes too.

```bash
npm pkg fix -w react-infinite-scroll-hook
```

## Publishing the Package

Firstly, we need to bump the package version which can be done by using the below commands.

```bash
npm version patch -w react-infinite-scroll-hook
# Bumps the patch number like 0.0.0 -> 0.0.1

npm version minor -w react-infinite-scroll-hook
# Bumps the patch number like 0.0.x -> 0.1.0

npm version major -w react-infinite-scroll-hook
# Bumps the patch number like 0.x.y -> 1.0.0
```

And we can publish the new version now 🚀

```bash
npm publish -w react-infinite-scroll-hook
```
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 onderonur
Copyright (c) 2019 onderonur

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ 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.
SOFTWARE.
Loading

0 comments on commit ba6ce6e

Please sign in to comment.