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 11, 2024
1 parent b18463d commit d0348bf
Show file tree
Hide file tree
Showing 48 changed files with 2,948 additions and 1,941 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-intersection-observer-hook/README.md"],
"imageSize": 100,
"commit": true,
"commitConvention": "none",
Expand All @@ -16,5 +16,6 @@
"contributions": ["code"]
}
],
"contributorsPerLine": 7
"contributorsPerLine": 7,
"linkToUsage": true
}
10 changes: 0 additions & 10 deletions .eslintrc.js

This file was deleted.

73 changes: 73 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# 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:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Restore cache
uses: actions/cache@v4
with:
path: |
.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Install dependencies
run: npm ci
- name: Build with Next.js
run: npm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./apps/demo/out

# Deployment job
deploy:
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
14 changes: 8 additions & 6 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 @@ -23,7 +25,7 @@ jobs:
uses: ./.github/composite-actions/install

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

lint:
name: Lint
Expand All @@ -36,7 +38,7 @@ jobs:
uses: ./.github/composite-actions/install

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

typecheck:
name: Typecheck
Expand All @@ -49,7 +51,7 @@ jobs:
uses: ./.github/composite-actions/install

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

build:
name: Build
Expand Down
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
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use the files.associations setting to tell VS Code to always open .css files in Tailwind CSS mode:
// https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss
"files.associations": {
"*.css": "tailwindcss"
},
// By default VS Code will not trigger completions when editing "string" content,
// for example within JSX attribute values.
// Updating the editor.quickSuggestions setting may improve your experience:
// https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss
"editor.quickSuggestions": {
"strings": "on"
}
}
134 changes: 134 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# 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-intersection-obverser-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-intersection-observer-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-intersection-observer-hook

# For `Are the Types Wrong`
npm run attw:check -w react-intersection-observer-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-intersection-observer-hook` package.

```bash
npm pack -w react-intersection-observer-hook
```

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

```bash
npm pack --dry-run -w react-intersection-observer-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-intersection-observer-hook
```

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

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

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

npm version major -w react-intersection-observer-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-intersection-observer-hook
```
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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 d0348bf

Please sign in to comment.