Skip to content

Commit ba6ce6e

Browse files
committed
migrating to turborepo & tsup continued
1 parent 1708584 commit ba6ce6e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3487
-1869
lines changed

.all-contributorsrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"projectOwner": "onderonur",
44
"repoType": "github",
55
"repoHost": "https://github.com",
6-
"files": ["README.md"],
6+
"files": ["./packages/react-infinite-scroll-hook/README.md"],
77
"imageSize": 100,
88
"commit": true,
99
"commitConvention": "none",
@@ -30,5 +30,6 @@
3030
"contributions": ["example"]
3131
}
3232
],
33-
"contributorsPerLine": 7
33+
"contributorsPerLine": 7,
34+
"linkToUsage": true
3435
}

.eslintrc.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/nextjs.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# https://github.com/actions/starter-workflows/blob/main/pages/nextjs.yml
2+
# Sample workflow for building and deploying a Next.js site to GitHub Pages
3+
#
4+
# To get started with Next.js see: https://nextjs.org/docs/getting-started
5+
#
6+
name: Deploy Next.js site to Pages
7+
8+
on:
9+
# Runs when `Quality` workflow gets completed on `main` branch
10+
workflow_run:
11+
branches: ['main']
12+
workflows: ['Quality']
13+
types:
14+
- completed
15+
# Allows you to run this workflow manually from the Actions tab
16+
workflow_dispatch:
17+
18+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
19+
permissions:
20+
contents: read
21+
pages: write
22+
id-token: write
23+
24+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
25+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
26+
concurrency:
27+
group: 'pages'
28+
cancel-in-progress: false
29+
30+
jobs:
31+
# Build job
32+
build:
33+
# Since `workflow_run` only has 3 activity types (`completed`, `requested` and `in_progress`),
34+
# even if `Quality` workflow gets completed by failing, this workflow starts to run.
35+
# To prevent this, we add a condition here.
36+
# https://github.com/orgs/community/discussions/26238#discussioncomment-3250901
37+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
- name: Setup Pages
43+
uses: actions/configure-pages@v5
44+
- name: Install
45+
uses: ./.github/composite-actions/install
46+
- name: Build with Next.js
47+
run: npm run build -- --filter=demo
48+
- name: Upload artifact
49+
uses: actions/upload-pages-artifact@v3
50+
with:
51+
path: ./apps/demo/out
52+
53+
# Deployment job
54+
deploy:
55+
# Since `workflow_run` only has 3 activity types (`completed`, `requested` and `in_progress`),
56+
# even if `Quality` workflow gets completed by failing, this workflow starts to run.
57+
# To prevent this, we add a condition here.
58+
# https://github.com/orgs/community/discussions/26238#discussioncomment-3250901
59+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
60+
environment:
61+
name: github-pages
62+
url: ${{ steps.deployment.outputs.page_url }}
63+
runs-on: ubuntu-latest
64+
needs: build
65+
steps:
66+
- name: Deploy to GitHub Pages
67+
id: deployment
68+
uses: actions/deploy-pages@v4

.github/workflows/quality.yml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ name: Quality
22

33
on:
44
push:
5-
branches:
6-
# TODO: This will be replaced with `main` later.
7-
- monorepo
5+
branches: ['main']
6+
pull_request:
7+
branches: ['main']
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
810

911
# To cancel previous workflow when a new one is triggered.
1012
concurrency:
@@ -18,48 +20,40 @@ jobs:
1820
steps:
1921
- name: Check out
2022
uses: actions/checkout@v4
21-
2223
- name: Install
2324
uses: ./.github/composite-actions/install
24-
2525
- name: Run format check
26-
run: npm run format
26+
run: npm run format:check
2727

2828
lint:
2929
name: Lint
3030
runs-on: ubuntu-latest
3131
steps:
3232
- name: Check out
3333
uses: actions/checkout@v4
34-
3534
- name: Install
3635
uses: ./.github/composite-actions/install
37-
3836
- name: Run lint check
39-
run: npm run lint
37+
run: npm run lint:check
4038

4139
typecheck:
4240
name: Typecheck
4341
runs-on: ubuntu-latest
4442
steps:
4543
- name: Check out
4644
uses: actions/checkout@v4
47-
4845
- name: Install
4946
uses: ./.github/composite-actions/install
50-
5147
- name: Run type check
52-
run: npm run typecheck
48+
run: npm run types:check
5349

5450
build:
5551
name: Build
5652
runs-on: ubuntu-latest
5753
steps:
5854
- name: Check out
5955
uses: actions/checkout@v4
60-
6156
- name: Install
6257
uses: ./.github/composite-actions/install
63-
6458
- name: Run build
6559
run: npm run build

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ out/
2727
build
2828
dist
2929

30-
3130
# Debug
3231
npm-debug.log*
3332
yarn-debug.log*

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
npx lint-staged
2-
npm run typecheck
2+
npm run types:check

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

CONTRIBUTING.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Contributing
2+
3+
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).
4+
5+
## Local Development
6+
7+
After cloning the repository, we need to install the dependencies.
8+
9+
```bash
10+
npm install
11+
```
12+
13+
To start the demo Next.js app which uses the local version of `react-infinite-scroll-hook`, we can run `dev` script.
14+
15+
```bash
16+
npm run dev
17+
```
18+
19+
After this, we can open `http://localhost:3000` in the browser to display the app.
20+
21+
## Code Quality Checks
22+
23+
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.
24+
25+
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).
26+
27+
The checks can be run manually by running the below command too.
28+
29+
```bash
30+
npm run codequality:check
31+
```
32+
33+
And the same checks can be run also by enabling fixes for auto-fixable issues.
34+
35+
```bash
36+
npm run codequality:fix
37+
```
38+
39+
`codequality` scripts run underlying ESLint (`lint`), Prettier (`format`) and TypeScript (`types`) scripts. To run these tools individually, we can also use the below scripts.
40+
41+
```bash
42+
# ESLint checks
43+
npm run lint:check
44+
# ESLint fixes
45+
npm run lint:fix
46+
47+
# Prettier checks
48+
npm run format:check
49+
# Prettier fixes
50+
npm run format:fix
51+
52+
# TypeScript checks
53+
npm run types:check
54+
# There is no auto-fix script for TypeScript.
55+
```
56+
57+
## Updating Dependencies
58+
59+
We use `npm-check-updates` package to automatically check if there are newer versions of our dependencies.
60+
61+
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.
62+
63+
```bash
64+
npm run updates:check
65+
```
66+
67+
## Adding Contributors
68+
69+
[all-contributors-cli](https://github.com/all-contributors/cli) is used for maintaining the contributors of this repository.
70+
71+
To add a new contributor, we can run the below command and follow its instructions.
72+
73+
```bash
74+
npm run contributors:add
75+
```
76+
77+
## Prepublish Checks
78+
79+
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).
80+
81+
Firstly, we need to build the bundle with the latest changes.
82+
83+
```bash
84+
npm run build:bundle
85+
```
86+
87+
This command will create (or update) the `packages/react-infinite-scroll-hook/dist` folder, which will be used by the clients of this package.
88+
89+
To be sure the output is OK for ESM and CJS clients, we can run the below commands and check their outputs.
90+
91+
```bash
92+
# For `publint`
93+
npm run publint:check -w react-infinite-scroll-hook
94+
95+
# For `Are the Types Wrong`
96+
npm run attw:check -w react-infinite-scroll-hook
97+
```
98+
99+
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.
100+
101+
```bash
102+
npm pack -w react-infinite-scroll-hook
103+
```
104+
105+
Or the below command can be used to only check the tarball contents without creating it.
106+
107+
```bash
108+
npm pack --dry-run -w react-infinite-scroll-hook
109+
```
110+
111+
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.
112+
113+
```bash
114+
npm pkg fix -w react-infinite-scroll-hook
115+
```
116+
117+
## Publishing the Package
118+
119+
Firstly, we need to bump the package version which can be done by using the below commands.
120+
121+
```bash
122+
npm version patch -w react-infinite-scroll-hook
123+
# Bumps the patch number like 0.0.0 -> 0.0.1
124+
125+
npm version minor -w react-infinite-scroll-hook
126+
# Bumps the patch number like 0.0.x -> 0.1.0
127+
128+
npm version major -w react-infinite-scroll-hook
129+
# Bumps the patch number like 0.x.y -> 1.0.0
130+
```
131+
132+
And we can publish the new version now 🚀
133+
134+
```bash
135+
npm publish -w react-infinite-scroll-hook
136+
```

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 onderonur
3+
Copyright (c) 2019 onderonur
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

0 commit comments

Comments
 (0)