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

Custom generator #449

Merged
merged 54 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 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
e9094a5
Merge branch 'main' into feat/generator-custom
cregourd Nov 8, 2024
01f03b0
Fix merging issue
cregourd Nov 8, 2024
d4e4d6e
Fix CI and build command
cregourd Nov 12, 2024
945eaa6
Remove yarn lock
cregourd Nov 12, 2024
c872810
Restoe clean command
cregourd Nov 12, 2024
a2defb1
Add install before vercel build
cregourd Nov 12, 2024
65ecfcb
Remove intermediate cleanup CI
cregourd Nov 12, 2024
172366b
Remove uneccessary deps in docs
cregourd Nov 13, 2024
ca5109f
Add new version openssl for prisma client
cregourd Nov 13, 2024
981f7b4
Revert eslint upgrade
cregourd Nov 13, 2024
2312b13
Last prerelease
cregourd Nov 13, 2024
adb2c5d
Explictly install lodash.debounce
cregourd Nov 13, 2024
5d78cc8
Exit prerelease mode
cregourd Nov 13, 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
2 changes: 1 addition & 1 deletion .changeset/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const getDependencyReleaseLine = async (

const changesetLinks = changesets.map(
(changeset) => {
const commitShortId = changeset.commit.slice(0, 7);
const commitShortId = changeset.commit?.slice(0, 7);
const commitLink = options?.repo ? `[${commitShortId}](https://github.com/${options.repo}/commit/${changeset.commit})` : commitShortId;
return `- Updated dependencies${changeset.commit ? ` [${commitLink}]` : ""
}`;
Expand Down
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/
8 changes: 8 additions & 0 deletions .changeset/giant-terms-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@premieroctet/next-admin-generator-prisma": patch
"@premieroctet/next-admin-json-schema": patch
"@premieroctet/next-admin": patch
"@premieroctet/next-admin-cli": patch
---

Fix generator
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/modern-shirts-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@premieroctet/next-admin": patch
---

Explictly install lodash.debounce
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
24 changes: 24 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"mode": "exit",
"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",
"giant-terms-march",
"lemon-bears-attend",
"modern-shirts-kick",
"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
10 changes: 5 additions & 5 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 build

- 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 All @@ -45,9 +48,6 @@ jobs:
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_DOCS }}

- name: Intermediate cleanup
run: rm -rf .vercel

- name: Pull Vercel Environment Information (Example)
run: vercel pull --yes --environment=${{ inputs.environment }} --token=${{ secrets.VERCEL_TOKEN }}
env:
Expand Down
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
link-workspace-packages=true
prefer-workspace-packages=true
prefer-symlinked-executables=true
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
2 changes: 1 addition & 1 deletion apps/docs/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
11 changes: 5 additions & 6 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,31 @@
"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.8",
"clsx": "^2.1.0",
"framer-motion": "^11.0.8",
"mini-svg-data-uri": "^1.4.4",
"next": "^13.1.1",
"next": "^15.0.3",
"nextra": "^2.13.2",
"nextra-theme-docs": "^2.13.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tailwind-merge": "^2.2.1"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@types/node": "^17.0.12",
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0",
"autoprefixer": "^10.0.1",
"eslint": "7.32.0",
"eslint-config-custom": "workspace:*",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"tailwindcss": "^3.4.14",
"tsconfig": "workspace:*",
"typescript": "^4.5.3"
"typescript": "^5.6.3"
}
}
Loading
Loading