Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom generator #449

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
acc0672
feat: custom generator
foyarash Sep 30, 2024
bc6dadd
fix workspace deps
foyarash Oct 1, 2024
c61996b
remove all occurrences of dmmf
foyarash Oct 2, 2024
937cf7f
finish dmmf migration
foyarash Oct 2, 2024
7458098
update test schema
foyarash Oct 2, 2024
11f2c9d
remove dmmf from mock prisma client
foyarash Oct 2, 2024
1fa56bc
add changesets
foyarash Oct 2, 2024
13c25cb
remove prisma generate from postinstall
foyarash Oct 2, 2024
eecf9dc
fix CI
foyarash Oct 2, 2024
124d6cf
fix syntax error
foyarash Oct 2, 2024
cef72f3
fix CI
foyarash Oct 2, 2024
2167cc2
generate Prisma client in E2E
foyarash Oct 2, 2024
9390519
add clean script, update generator output
foyarash Oct 2, 2024
70eb7b9
remove schema import and legacy json schema
foyarash Oct 2, 2024
31d768a
update docs, remove schema in cli templates
foyarash Oct 2, 2024
3386985
add jsdoc to json schema relation type
foyarash Oct 3, 2024
363ea53
update docs
foyarash Oct 3, 2024
82ff7ee
update readme
foyarash Oct 3, 2024
4474731
fix repository paths
foyarash Oct 3, 2024
60028df
Merge branch main into feat/generator-custom
cregourd Oct 7, 2024
900b0b5
Merge branch 'main' into feat/generator-custom
cregourd Oct 7, 2024
2aa241a
Release Candidate mode
cregourd Oct 7, 2024
02ae70a
Merge branch 'main' into feat/generator-custom
cregourd Oct 9, 2024
f82be4e
Fix vercel version
cregourd Oct 9, 2024
6e060f2
Add changeset
cregourd Oct 9, 2024
6f9d0a0
RC 1
cregourd Oct 9, 2024
7589800
yarn.lock issue
cregourd Oct 9, 2024
4b60181
RC 1 - Change dependendcy
cregourd Oct 11, 2024
912f782
Apply dist folder to cli
cregourd Oct 28, 2024
b13c11e
Next admin json schema to devDeps
cregourd Oct 28, 2024
e9447a8
Change to pnpm
cregourd Oct 29, 2024
fed9dd9
Upgrade json schema
cregourd Oct 29, 2024
aa50b6c
fix pnpm
cregourd Oct 30, 2024
29971f5
upgrade release
cregourd Oct 30, 2024
4a8ee60
Fix CI
cregourd Oct 30, 2024
12ee310
Fix CI
cregourd Oct 30, 2024
7adb25a
Fix e2e ci
cregourd Oct 30, 2024
4ebc483
Remove prettier from overrides
cregourd Oct 30, 2024
cf4d433
Add playwright deps
cregourd Oct 30, 2024
16a9fdc
Finish convert to pnpm
cregourd Oct 31, 2024
30b3421
Change CI and fix CONTRIBUTING.md
cregourd Oct 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cool-meals-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@premieroctet/next-admin": major
---

feat: add custom generator (#414)
6 changes: 6 additions & 0 deletions .changeset/fifty-chairs-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@premieroctet/next-admin-generator-prisma": patch
"@premieroctet/next-admin-json-schema": patch
---

feat: new json-schema libraries (#414)
5 changes: 5 additions & 0 deletions .changeset/four-comics-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@premieroctet/next-admin-cli": patch
---

Apply dist/
5 changes: 5 additions & 0 deletions .changeset/lemon-bears-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@premieroctet/next-admin-cli": patch
---

feat: support new generator (#414)
5 changes: 5 additions & 0 deletions .changeset/nasty-clouds-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@premieroctet/next-admin-generator-prisma": patch
---

Change next-admin-json-schema dependenciy
22 changes: 22 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"mode": "pre",
"tag": "rc",
"initialVersions": {
"docs": "0.0.0",
"example": "0.0.0",
"@premieroctet/next-admin-cli": "0.0.4",
"eslint-config-custom": "0.0.0",
"@premieroctet/next-admin-generator-prisma": "0.0.0",
"@premieroctet/next-admin-json-schema": "0.0.0",
"@premieroctet/next-admin": "6.1.5",
"tsconfig": "0.0.0"
},
"changesets": [
"cool-meals-obey",
"fifty-chairs-travel",
"four-comics-deny",
"lemon-bears-attend",
"nasty-clouds-deny",
"sour-garlics-dress"
]
}
5 changes: 5 additions & 0 deletions .changeset/sour-garlics-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@premieroctet/next-admin": patch
---

Merge main
4 changes: 2 additions & 2 deletions .github/workflows/check-changeset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:
with:
node-version: 20
- name: Install dependencies
run: yarn install
run: pnpm install
- name: Check for changeset
run: yarn changeset status
run: pnpm changeset status
26 changes: 14 additions & 12 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,38 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 20
cache: "yarn"
cache: "pnpm"
- name: Cache playwright dependencies
id: cache-playwright
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Start docker-compose
run: docker compose up -d
- name: Install dependencies
run: yarn install
run: pnpm install
- name: Setup packages (Build)
run: pnpm setup:packages
- name: Run linter
run: yarn lint
run: pnpm lint
- name: Run typecheck
run: yarn typecheck
run: pnpm typecheck
- name: Install playwright dependencies
if: steps.cache-playwright.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
- name: Fill database
run: yarn database
run: pnpm database
- name: Build packages
run: yarn build:example
run: pnpm build:example
- name: Start server
run: yarn start:example &
run: pnpm start:example &
- name: Run tests
run: |
yarn test
yarn turbo test:e2e
cd apps/example && yarn prisma db seed && cd -
BASE_URL=http://localhost:3000/pagerouter/admin yarn test:e2e
pnpm test
pnpm turbo test:e2e
cd apps/example && pnpm prisma db seed && cd -
BASE_URL=http://localhost:3000/pagerouter/admin pnpm test:e2e
- uses: actions/upload-artifact@v3
if: always()
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ jobs:
node-version: 20

- name: Install Dependencies
run: yarn install
run: pnpm install

- name: Link
run: yarn lint
- name: Lint
run: pnpm lint

- name: Create Release Pull Request or Publish (${{ github.ref_name }})
uses: changesets/action@v1
with:
version: yarn changeset-version
publish: yarn publish-package
version: pnpm changeset-version
publish: pnpm publish-packages
title: ${{github.ref_name}} — Version Packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reset-database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
- name: Enable corepack
run: corepack enable
- name: Install dependencies
run: yarn install
run: pnpm install
- name: Reset database
env:
POSTGRES_PRISMA_URL: ${{ secrets.POSTGRES_PRISMA_URL }}
POSTGRES_URL_NON_POOLING: ${{ secrets.POSTGRES_URL_NON_POOLING }}
run: yarn reset-database
run: pnpm reset-database
7 changes: 5 additions & 2 deletions .github/workflows/vercel-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ jobs:
node-version: 20

- name: Install Dependencies
run: yarn install
run: pnpm install

- name: Setup packages (Build)
run: pnpm setup:packages

- name: Install Vercel CLI
run: npm install --global vercel@latest
run: npm install --global vercel@37.6.1

- name: Pull Vercel Environment Information (Docs)
run: vercel pull --yes --environment=${{ inputs.environment }} --token=${{ secrets.VERCEL_TOKEN }}
Expand Down
1 change: 0 additions & 1 deletion .yarnrc.yml

This file was deleted.

81 changes: 57 additions & 24 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ An auto generated admin from Prisma models for your Next.js app.

### Apps and Packages

- `docs`: a [Next.js](https://nextjs.org/) app
- `web`: another [Next.js](https://nextjs.org/) app
- `next-admin`: the admin library used by both `web` and `docs` applications
- `eslint-config-custom`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`)
- `tsconfig`: `tsconfig.json`s used throughout the monorepo
- `apps/docs`: a [Next.js](https://nextjs.org/) app
- `apps/example`: a [Next.js](https://nextjs.org/) app that uses the `next-admin` package
- `packages/next-admin`: the admin library used by both `web` and `docs` applications
- `packages/cli`: a CLI to generate the admin in your Next.js app
- `packages/generator-prisma`: a CLI to generate a json schema of your Prisma models
- `packages/json-schema`: a packages to normalize the Prisma schema to a json schema (primarily used to type the generated and next-admin packages)
- `packages/eslint-config-custom`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`)
- `packagestsconfig`: `tsconfig.json`s used throughout the monorepo

### Utilities

Expand All @@ -20,6 +23,54 @@ This turborepo has some additional tools already setup for you:
- [ESLint](https://eslint.org/) for code linting
- [Prettier](https://prettier.io) for code formatting

### Setup

To setup the project, run the following command:

```
pnpm install
```

Then you need to create a `.env` file in the `apps/example` project with the following content:

```
DATABASE_URL="postgresql://user:password@localhost:5432/dbname"
```

And run the following command to setup the packages:

```
pnpm setup:packages
```

The `setup:packages` command will build packages, generate Prisma and then build `next-admin` package.

### Prisma (first time setup)

To setup the database, run the following command:

```
pnpm database
```

### Develop

To develop all apps and packages, run the following command:

```
pnpm dev
docker-compose up
cd apps/example && pnpm database
```

### Build

To build all apps and packages, run the following command:

```
pnpm build
```

### Workflow

The project workflow uses GitHub Actions to run tests, build, deploy (prod - preview - docs) and publish packages. To handle versioning up and publishing, we use [Changesets](https://github.com/changesets/changesets)
Expand All @@ -29,7 +80,7 @@ The project workflow uses GitHub Actions to run tests, build, deploy (prod - pre
To increase the version of a package, you need to create a `changeset` file. You can create a `changeset` file by running the following command:

```sh
yarn changeset
pnpm changeset
```

Any PR without a `changeset` file will just trigger the tests and eventually deploy/preview the app.
Expand All @@ -52,24 +103,6 @@ If you want to fix a previous major version, you can create a PR on the relative

Once a fix has been released, you can cherry-pick the fix on the `develop` branch if that fix is still relevant.

### Build

To build all apps and packages, run the following command:

```
yarn run build
```

### Develop

To develop all apps and packages, run the following command:

```
yarn run dev
docker-compose up
cd apps/example && yarn database
```

### E2E

Tests are using Playwright to test directly with a browser.
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
First, run the development server:

```bash
yarn dev
pnpm dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
Expand Down
5 changes: 3 additions & 2 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
"dev": "next dev --port 3001",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"clean": "rm -rf .next"
},
"dependencies": {
"@heroicons/react": "^2.1.1",
"@premieroctet/next-admin": "6.1.6",
"@premieroctet/next-admin": "7.0.0-rc.1",
"clsx": "^2.1.0",
"framer-motion": "^11.0.8",
"mini-svg-data-uri": "^1.4.4",
Expand Down
24 changes: 12 additions & 12 deletions apps/docs/pages/docs/api/create-handler-function.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

import { Callout, Tabs } from "nextra/components";
import OptionsTable from "../../../components/OptionsTable";

# `createHandler` function

<Callout type="info">
This is the documentation for the latest version of Next Admin. If you are using an older version (`<5.0.0`), please refer to the [documentation](/v4/docs)
</Callout>
Expand All @@ -12,21 +12,21 @@ import OptionsTable from "../../../components/OptionsTable";
<OptionsTable
options={[
{
name: 'prisma',
description: 'Your Prisma client instance. This is mandatory.'
},
{
name: 'schema',
description: 'Your JSON Schema generated by Prisma. This is mandatory.'
name: "prisma",
description: "Your Prisma client instance. This is mandatory.",
},
{
name: 'onRequest',
description: 'A function that is executed before any request. Useful for authentication.'
name: "onRequest",
description:
"A function that is executed before any request. Useful for authentication.",
},
{
name: 'options',
description: <>Your Next Admin <a href="/docs/api/options">options</a> - optional. </>
name: "options",
description: (
<>
Your Next Admin <a href="/docs/api/options">options</a> - optional.{" "}
</>
),
},

]}
/>
13 changes: 3 additions & 10 deletions apps/docs/pages/docs/api/get-next-admin-props-function.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

import { Callout, Tabs } from "nextra/components";
import OptionsTable from "../../../components/OptionsTable";

# `getNextAdminProps` function

<Callout type="info">
This is the documentation for the latest version of Next Admin. If you are using an older version (`<5.0.0`), please refer to the [documentation](/v4/docs)
</Callout>
Expand Down Expand Up @@ -31,10 +31,6 @@ import OptionsTable from "../../../components/OptionsTable";
name: 'apiBasePath',
description: 'The base path of your admin API. It is used to build the admin API URL. It is mandatory.'
},
{
name: 'schema',
description: <>The JSON schema generated by the <code>prisma generate</code> command.</>
},
{
name: 'prisma',
description: 'Your Prisma client instance.'
Expand Down Expand Up @@ -70,10 +66,6 @@ import OptionsTable from "../../../components/OptionsTable";
name: 'apiBasePath',
description: <>The base path of your admin API. It is used to build the admin API URL. It is optional and defaults to <code>/api/admin</code>.</>
},
{
name: 'schema',
description: <>The JSON schema generated by the <code>prisma generate</code> command.</>
},
{
name: 'prisma',
description: 'Your Prisma client instance.'
Expand All @@ -94,8 +86,9 @@ import OptionsTable from "../../../components/OptionsTable";
name: 'options',
description: <>The <a href="/docs/api/options">options</a> object - optional.</>
}

]}
/>

</Tabs.Tab>
</Tabs>
Loading
Loading