Skip to content

Commit

Permalink
refactor: restructure monorepo (#104)
Browse files Browse the repository at this point in the history
Switch to pnpm workspaces, rename "example app" to "playground", update license to BSD-3-Clause.
  • Loading branch information
TheEdoRan committed Apr 24, 2024
1 parent 3935e9f commit 58373ab
Show file tree
Hide file tree
Showing 78 changed files with 18,804 additions and 29,360 deletions.
30 changes: 19 additions & 11 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ name: CI/CD

on:
push:
paths:
- "packages/**"
branches:
- main
- alpha
- beta
- next
- 4.x
pull_request:
paths:
- "packages/**"
branches:
- "*"

Expand All @@ -19,31 +21,37 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- run: npm ci
- run: npm run lint -- --filter=next-safe-action
cache: "pnpm"
- run: pnpm install --frozen-lockfile
- run: pnpm run lint:lib

CD:
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/alpha' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/next'|| github.ref == 'refs/heads/4.x' }}
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/next'|| github.ref == 'refs/heads/4.x' }}
runs-on: ubuntu-latest
needs: [CI]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: pnpm/action-setup@v3
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- run: npm ci
- run: npm run build -- --filter=next-safe-action
- name: Release
cache: "pnpm"
- run: pnpm install --frozen-lockfile
- run: pnpm run build:lib
- name: Release lib to NPM
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run deploy -- --filter=next-safe-action
run: pnpm run deploy:lib
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx commitlint --edit "${1}"
pnpm exec commitlint --edit "${1}"
2 changes: 1 addition & 1 deletion .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

exec < /dev/tty && npx cz --hook || true
exec < /dev/tty && pnpm exec cz --hook || true
153 changes: 0 additions & 153 deletions .releaserc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"eslint.validate": ["typescript"],
"eslint.validate": ["typescript", "typescriptreact"],
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll.eslint": "explicit"
Expand Down
41 changes: 24 additions & 17 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
MIT License
BSD 3-Clause License

Copyright (c) 2023 Edoardo Ranghieri
Copyright (c) 2023, Edoardo Ranghieri

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
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.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 changes: 6 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,17 @@ https://github.com/TheEdoRan/next-safe-action/assets/1337629/7ebc398e-6c7d-49b2-

## Documentation

**Explore the documentation for the current library version on [next-safe-action website](https://next-safe-action.dev).**
**Explore the documentation for the next version of the library on the [next-safe-action website](https://next.next-safe-action.dev).**

## Next.js >= 14 vs 13

Server Actions are now a stable feature in React. For this reason, there were some internal breaking changes to the API, and so a new version of the library is required to prevent backward compatibility issues.

**You can continue to use `next-safe-action` version 4 for your Next.js 13 app.**
## Installation

```bash
npm i next-safe-action # for Next.js >= 14
npm i next-safe-action@next
```

```bash
npm i next-safe-action@v4 # for Next.js 13
```

## Migration guide

Version 7.x.x of the library supports form actions and improves validation errors handling. Please check out the [v6 to v7 migration guide](https://next-safe-action.dev/docs/migrations/v6-to-v7) on the website for more information.

## Example
## Playground

You can find a basic working implementation of the library [here](packages/example-app).
You can find a basic working implementation of the library [here](apps/playground).

## Contributing

Expand All @@ -62,4 +50,4 @@ Made with [contrib.rocks](https://contrib.rocks).

## License

next-safe-action is released under the MIT license.
next-safe-action is released under the [BSD-3-Clause License](https://opensource.org/license/bsd-3-clause).
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions apps/playground/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Try it yourself: [Link to example on Vercel](https://next-safe-action-playground.vercel.app/).

This is a basic implementation of the [next-safe-action](../../packages/next-safe-action) library.
File renamed without changes.
25 changes: 11 additions & 14 deletions packages/example-app/package.json → apps/playground/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "example-app",
"name": "@apps/playground",
"version": "0.0.0",
"private": true,
"scripts": {
Expand All @@ -8,31 +8,28 @@
"start": "next start",
"lint": "next lint"
},
"license": "MIT",
"author": "Edoardo Ranghieri",
"dependencies": {
"@hookform/resolvers": "^3.3.4",
"@typeschema/valibot": "^0.13.4",
"@typeschema/zod": "^0.13.3",
"lucide-react": "^0.364.0",
"next": "14.1.4",
"next-safe-action": "file:../next-safe-action",
"lucide-react": "^0.372.0",
"next": "14.2.2",
"next-safe-action": "workspace:*",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.51.2",
"valibot": "^0.30.0",
"zod": "^3.22.4",
"react-hook-form": "^7.51.3",
"zod": "^3.23.4",
"zod-form-data": "^2.0.2"
},
"devDependencies": {
"@types/node": "^20.12.3",
"@types/react": "^18.2.74",
"@types/react-dom": "18.2.23",
"@types/node": "^20.12.7",
"@types/react": "^18.2.79",
"@types/react-dom": "18.2.25",
"autoprefixer": "10.4.19",
"eslint": "^8.57.0",
"eslint-config-next": "14.1.4",
"eslint-config-next": "14.2.2",
"postcss": "8.4.38",
"tailwindcss": "3.4.3",
"typescript": "^5.4.3"
"typescript": "^5.4.5"
}
}
File renamed without changes.

0 comments on commit 58373ab

Please sign in to comment.