Skip to content
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
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly

- package-ecosystem: "npm"
directory: "/"
schedule:
interval: weekly

target-branch: dev

59 changes: 59 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build and Test

on:
pull_request:
branches:
- main
- dev

env:
TELEMETRY_TRACKING_TOKEN: ${{ secrets.TELEMETRY_TRACKING_TOKEN }}
DO_NOT_TRACK: "1"

permissions:
contents: read

jobs:
build-test:
runs-on: buildjet-8vcpu-ubuntu-2204

strategy:
matrix:
node-version: [20.x]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 10.12.1

- name: Use Node.js ${{ matrix.node-version }}
uses: buildjet/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Setup pnpm cache
uses: buildjet/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: |
pnpm run build
pnpm tsx scripts/post-build.ts
77 changes: 77 additions & 0 deletions .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Claude Code Review

on:
pull_request:
types: [opened, synchronize]
# Optional: Only run on specific file changes
# paths:
# - "src/**/*.ts"
# - "src/**/*.tsx"
# - "src/**/*.js"
# - "src/**/*.jsx"

jobs:
claude-review:
# Optional: Filter by PR author
# if: |
# github.event.pull_request.user.login == 'external-contributor' ||
# github.event.pull_request.user.login == 'new-developer' ||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: read
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@beta
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}

# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
# model: "claude-opus-4-20250514"

# Direct prompt for automated review (no @claude mention needed)
direct_prompt: |
Please review this pull request and provide feedback on:
- Code quality and best practices
- Potential bugs or issues
- Performance considerations
- Security concerns
- Test coverage

Be constructive and helpful in your feedback.

# Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR
# use_sticky_comment: true

# Optional: Customize review based on file types
# direct_prompt: |
# Review this PR focusing on:
# - For TypeScript files: Type safety and proper interface usage
# - For API endpoints: Security, input validation, and error handling
# - For React components: Performance, accessibility, and best practices
# - For tests: Coverage, edge cases, and test quality

# Optional: Different prompts for different authors
# direct_prompt: |
# ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' &&
# 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' ||
# 'Please provide a thorough code review focusing on our coding standards and best practices.' }}

# Optional: Add specific tools for running tests or linting
# allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)"

# Optional: Skip review for certain conditions
# if: |
# !contains(github.event.pull_request.title, '[skip-review]') &&
# !contains(github.event.pull_request.title, '[WIP]')
85 changes: 85 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Publish and Release

on:
workflow_dispatch:
push:
branches:
- main
env:
TELEMETRY_TRACKING_TOKEN: ${{ secrets.TELEMETRY_TRACKING_TOKEN }}
DO_NOT_TRACK: "1"

permissions:
contents: write

jobs:
publish-and-release:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 10.12.1

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "pnpm"
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: |
pnpm run build
pnpm tsx scripts/post-build.ts

- name: Get version from package.json
id: version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT

- name: Publish packages
run: pnpm run publish-all
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Generate changelog
id: changelog
run: |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")

if [ -z "$PREVIOUS_TAG" ]; then
CHANGELOG=$(git log --oneline --no-merges --format="* %s" HEAD)
else
CHANGELOG=$(git log --oneline --no-merges --format="* %s" ${PREVIOUS_TAG}..HEAD)
fi

if [ -z "$CHANGELOG" ]; then
CHANGELOG="* Automated release"
fi

echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ZenStack Proxy Release ${{ steps.version.outputs.tag }}
body: |
## Changes in this release

${{ steps.changelog.outputs.changelog }}
draft: true
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
build
dist
*.log
.env
.DS_Store
*.tsbuildinfo
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# ZenStack Proxy CLI

A CLI tool to run an Express server with ZenStack proxy integration directly from the command line.

## Installation

```bash
npm install zenstack-proxy
```

## Usage

### Start the Server

```bash
zenstack-proxy [options]
```

### Options

- `-z, --zenstack <path>` Path to ZenStack generated folder
- `-p, --port <number>` Port number for the server (default: `8008`)
- `-s --schema <path>` - Path to ZModel schema file (default: "schema.zmodel")
- `-d, --datasource-url <url>` Datasource URL (overrides schema configuration)
- `-l, --log <level...>` Query log levels (e.g., query, info, warn, error)

### Examples

#### Basic Usage

Start a server with default settings (searches for ZenStack output automatically):

```bash
zenstack-proxy
```

#### Specify ZenStack schema and generated output

```bash
zenstack-proxy -s ./schema/schema.zmodel -z ./generated/zenstack
```

#### Custom Port

```bash
zenstack-proxy -p 8888
```

## Server Endpoints

The server provides the following endpoints:

### ZenStack Model API

- `POST /api/model/:model/:operation` - All ZenStack operations (find, create, update, delete, etc.)

The ZenStack middleware handles all CRUD operations for your models.

### Metadata

- `GET /api/schema` - Get complete schema metadata (models + enums)

## License

MIT
44 changes: 44 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "zenstack-proxy",
"version": "0.2.0",
"description": "ZenStack Proxy CLI for ZenStack Studio",
"main": "index.js",
"publishConfig": {
"directory": "dist",
"linkDirectory": true
},
"bin": {
"zenstack-proxy": "./bin/cli.js"
},
"scripts": {
"clean": "rimraf dist",
"build": "pnpm clean && tsc && copyfiles -F \"bin/*\" dist && copyfiles ./README.md ./LICENSE ./package.json dist && pnpm pack dist --pack-destination ../build",
"prepublishOnly": "npm run build"
},
"keywords": ["zenstack", "proxy", "express", "cli"],
"author": "",
"license": "MIT",
"dependencies": {
"@prisma/adapter-better-sqlite3": "^6.2.1",
"@prisma/adapter-mariadb": "^7.1.0",
"@prisma/adapter-pg": "^6.18.0",
"@zenstackhq/server": "^2.0.0",
"colors": "^1.4.0",
"commander": "^12.0.0",
"cors": "^2.8.5",
"dotenv": "^17.2.3",
"express": "^4.19.2",
"mixpanel": "^0.19.1",
"semver": "^7.7.3",
"tsx": "^4.20.6"
},
"devDependencies": {
"@types/cors": "^2.8.17",
"@types/express": "^5.0.0",
"@types/node": "^20.0.0",
"@types/semver": "^7.7.1",
"copyfiles": "^2.4.1",
"rimraf": "^4.0.0",
"typescript": "^5.0.0"
}
}
Loading
Loading