Skip to content

Commit 3788dd1

Browse files
committed
migrating to turborepo & tsup continued
1 parent b18463d commit 3788dd1

48 files changed

Lines changed: 2934 additions & 1949 deletions

Some content is hidden

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

.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-intersection-observer-hook/README.md"],
77
"imageSize": 100,
88
"commit": true,
99
"commitConvention": "none",
@@ -16,5 +16,6 @@
1616
"contributions": ["code"]
1717
}
1818
],
19-
"contributorsPerLine": 7
19+
"contributorsPerLine": 7,
20+
"linkToUsage": true
2021
}

.eslintrc.js

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

.github/workflows/nextjs.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
- name: Setup Pages
38+
uses: actions/configure-pages@v5
39+
- name: Install
40+
uses: ./.github/composite-actions/install
41+
- name: Build with Next.js
42+
run: npm run build -- --filter=demo
43+
- name: Upload artifact
44+
uses: actions/upload-pages-artifact@v3
45+
with:
46+
path: ./apps/demo/out
47+
48+
# Deployment job
49+
deploy:
50+
environment:
51+
name: github-pages
52+
url: ${{ steps.deployment.outputs.page_url }}
53+
runs-on: ubuntu-latest
54+
needs: build
55+
steps:
56+
- name: Deploy to GitHub Pages
57+
id: deployment
58+
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

.vscode/settings.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
// Use the files.associations setting to tell VS Code to always open .css files in Tailwind CSS mode:
3+
// https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss
4+
"files.associations": {
5+
"*.css": "tailwindcss"
6+
},
7+
// By default VS Code will not trigger completions when editing "string" content,
8+
// for example within JSX attribute values.
9+
// Updating the editor.quickSuggestions setting may improve your experience:
10+
// https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss
11+
"editor.quickSuggestions": {
12+
"strings": "on"
13+
}
14+
}

CONTRIBUTING.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
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-intersection-obverser-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+
[all-contributors-cli](https://github.com/all-contributors/cli) is used for maintaining the contributors of this repository.
69+
70+
To add a new contributor, we can run the below command and follow its instructions.
71+
72+
```bash
73+
npm run contributors:add
74+
```
75+
76+
## Prepublish Checks
77+
78+
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).
79+
80+
Firstly, we need to build the bundle with the latest changes.
81+
82+
```bash
83+
npm run build:bundle
84+
```
85+
86+
This command will create (or update) the `packages/react-intersection-observer-hook/dist` folder, which will be used by the clients of this package.
87+
88+
To be sure the output is OK for ESM and CJS clients, we can run the below commands and check their outputs.
89+
90+
```bash
91+
# For `publint`
92+
npm run publint:check -w react-intersection-observer-hook
93+
94+
# For `Are the Types Wrong`
95+
npm run attw:check -w react-intersection-observer-hook
96+
```
97+
98+
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-intersection-observer-hook` package.
99+
100+
```bash
101+
npm pack -w react-intersection-observer-hook
102+
```
103+
104+
Or the below command can be used to only check the tarball contents without creating it.
105+
106+
```bash
107+
npm pack --dry-run -w react-intersection-observer-hook
108+
```
109+
110+
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.
111+
112+
```bash
113+
npm pkg fix -w react-intersection-observer-hook
114+
```
115+
116+
## Publish
117+
Firstly, we need to bump the package version which can be done by using the below commands.
118+
119+
```bash
120+
npm version patch -w react-intersection-observer-hook
121+
# Bumps the patch number like 0.0.0 -> 0.0.1
122+
123+
npm version minor -w react-intersection-observer-hook
124+
# Bumps the patch number like 0.0.x -> 0.1.0
125+
126+
npm version major -w react-intersection-observer-hook
127+
# Bumps the patch number like 0.x.y -> 1.0.0
128+
```
129+
130+
And we can publish the new version now 🚀
131+
132+
```bash
133+
npm publish -w react-intersection-observer-hook
134+
```

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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)