Skip to content

Commit

Permalink
Custom generator (#449)
Browse files Browse the repository at this point in the history
* feat: custom generator

* fix workspace deps

* remove all occurrences of dmmf

* finish dmmf migration

* update test schema

* remove dmmf from mock prisma client

* add changesets

* remove prisma generate from postinstall

* fix CI

* fix syntax error

* fix CI

* generate Prisma client in E2E

* add clean script, update generator output

* remove schema import and legacy json schema

* update docs, remove schema in cli templates

* add jsdoc to json schema relation type

* update docs

* update readme

* fix repository paths

* Merge branch main into feat/generator-custom

* Release Candidate mode

* Fix vercel version

* Add changeset

* RC 1

* yarn.lock issue

* RC 1 - Change dependendcy

* Apply dist folder to cli

* Next admin json schema to devDeps

* Change to pnpm

* Upgrade json schema

* fix pnpm

* upgrade release

* Fix CI

* Fix CI

* Fix e2e ci

* Remove prettier from overrides

* Add playwright deps

* Finish convert to pnpm

* Change CI and fix CONTRIBUTING.md

* Fix merging issue

* Fix CI and build command

* Remove yarn lock

* Restoe clean command

* Add install before vercel build

* Remove intermediate cleanup CI

* Remove uneccessary deps in docs

* Add new version openssl for prisma client

* Revert eslint upgrade

* Last prerelease

* Explictly install lodash.debounce

* Exit prerelease mode

---------

Co-authored-by: Colin Regourd <cregourd@premieroctet.com>
  • Loading branch information
foyarash and cregourd authored Nov 13, 2024
1 parent ae432ac commit 64737aa
Show file tree
Hide file tree
Showing 90 changed files with 15,295 additions and 17,538 deletions.
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

0 comments on commit 64737aa

Please sign in to comment.