Skip to content

dev to main #468

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

Merged
merged 4 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ The following diagram gives a high-level overview of how it works.

- Prisma schema generator
- Zod schema generator
- React hooks generator
- [SWR](https://github.com/vercel/swr) and [TanStack Query](https://github.com/TanStack/query) hooks generator
- OpenAPI specification generator
- [tRPC](https://trpc.io) router generator
- 🙋🏻 [Request for a plugin](https://go.zenstack.dev/chat)
Expand All @@ -135,14 +135,17 @@ The following diagram gives a high-level overview of how it works.
- [Custom attributes and functions](https://zenstack.dev/docs/reference/zmodel-language#custom-attributes-and-functions)
- [Multi-file schema and model inheritance](https://zenstack.dev/docs/guides/multiple-schema)
- Strong-typed JSON field (coming soon)
- Polymorphism (future)
- 🙋🏻 [Request for an extension](https://go.zenstack.dev/chat)

## Examples

Check out the [Collaborative Todo App](https://zenstack-todo.vercel.app/) for a running example. You can find the source code below:
Check out the [Collaborative Todo App](https://zenstack-todo.vercel.app/) for a running example. You can find different implementations below:

- [Next.js + React hooks implementation](https://github.com/zenstackhq/sample-todo-nextjs)
- [Next.js + tRPC implementation](https://github.com/zenstackhq/sample-todo-trpc)
- [Next.js + SWR hooks](https://github.com/zenstackhq/sample-todo-nextjs)
- [Next.js + TanStack Query](https://github.com/zenstackhq/sample-todo-nextjs-tanstack)
- [Next.js + tRPC](https://github.com/zenstackhq/sample-todo-trpc)
- [SvelteKit + TanStack Query](https://github.com/zenstackhq/sample-todo-sveltekit)

## Community

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenstack-monorepo",
"version": "1.0.0-alpha.125",
"version": "1.0.0-alpha.126",
"description": "",
"scripts": {
"build": "pnpm -r build",
Expand Down
2 changes: 1 addition & 1 deletion packages/language/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/language",
"version": "1.0.0-alpha.125",
"version": "1.0.0-alpha.126",
"displayName": "ZenStack modeling language compiler",
"description": "ZenStack modeling language compiler",
"homepage": "https://zenstack.dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/next",
"version": "1.0.0-alpha.125",
"version": "1.0.0-alpha.126",
"displayName": "ZenStack Next.js integration",
"description": "ZenStack Next.js integration",
"homepage": "https://zenstack.dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/openapi",
"displayName": "ZenStack Plugin and Runtime for OpenAPI",
"version": "1.0.0-alpha.125",
"version": "1.0.0-alpha.126",
"description": "ZenStack plugin and runtime supporting OpenAPI",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/react",
"displayName": "ZenStack plugin and runtime for ReactJS",
"version": "1.0.0-alpha.125",
"version": "1.0.0-alpha.126",
"description": "ZenStack plugin and runtime for ReactJS",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/swr/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/swr",
"displayName": "ZenStack plugin for generating SWR hooks",
"version": "1.0.0-alpha.125",
"version": "1.0.0-alpha.126",
"description": "ZenStack plugin for generating SWR hooks",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/tanstack-query/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/tanstack-query",
"displayName": "ZenStack plugin for generating tanstack-query hooks",
"version": "1.0.0-alpha.125",
"version": "1.0.0-alpha.126",
"description": "ZenStack plugin for generating tanstack-query hooks",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/trpc/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/trpc",
"displayName": "ZenStack plugin for tRPC",
"version": "1.0.0-alpha.125",
"version": "1.0.0-alpha.126",
"description": "ZenStack plugin for tRPC",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/runtime",
"displayName": "ZenStack Runtime Library",
"version": "1.0.0-alpha.125",
"version": "1.0.0-alpha.126",
"description": "Runtime of ZenStack for both client-side and server-side environments.",
"repository": {
"type": "git",
Expand Down
4 changes: 3 additions & 1 deletion packages/runtime/src/enhancements/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ function loadPrismaModule(prisma: any) {
if (prisma._engineConfig?.datamodelPath) {
const loadPath = path.dirname(prisma._engineConfig.datamodelPath);
try {
return require(loadPath).Prisma;
const _prisma = require(loadPath).Prisma;
if (typeof _prisma !== 'undefined') return _prisma;
return require('@prisma/client/runtime');
} catch {
return require('@prisma/client/runtime');
}
Expand Down
13 changes: 11 additions & 2 deletions packages/schema/src/plugins/plugin-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export const ALL_OPERATION_KINDS: PolicyOperationKind[] = ['create', 'update', '
*/
export function getNodeModulesFolder(startPath?: string): string | undefined {
startPath = startPath ?? process.cwd();
if (fs.existsSync(path.join(startPath, 'node_modules'))) {
if (startPath.endsWith('node_modules')) {
return startPath;
} else if (fs.existsSync(path.join(startPath, 'node_modules'))) {
return path.join(startPath, 'node_modules');
} else if (startPath !== '/') {
const parent = path.join(startPath, '..');
Expand All @@ -25,7 +27,14 @@ export function getNodeModulesFolder(startPath?: string): string | undefined {
*/
export function getDefaultOutputFolder() {
// Find the real runtime module path, it might be a symlink in pnpm
const runtimeModulePath = require.resolve('@zenstackhq/runtime');
let runtimeModulePath = require.resolve('@zenstackhq/runtime');
if (runtimeModulePath) {
// start with the parent folder of @zenstackhq, supposed to be a node_modules folder
while (!runtimeModulePath.endsWith('@zenstackhq') && runtimeModulePath !== '/') {
runtimeModulePath = path.join(runtimeModulePath, '..');
}
runtimeModulePath = path.join(runtimeModulePath, '..');
}
const modulesFolder = getNodeModulesFolder(runtimeModulePath);
return modulesFolder ? path.join(modulesFolder, '.zenstack') : undefined;
}
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/sdk",
"version": "1.0.0-alpha.125",
"version": "1.0.0-alpha.126",
"description": "ZenStack plugin development SDK",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/server",
"version": "1.0.0-alpha.125",
"version": "1.0.0-alpha.126",
"displayName": "ZenStack Server-side Adapters",
"description": "ZenStack server-side adapters",
"homepage": "https://zenstack.dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/testtools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/testtools",
"version": "1.0.0-alpha.125",
"version": "1.0.0-alpha.126",
"description": "ZenStack Test Tools",
"main": "index.js",
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test-run/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.