Skip to content

Commit 419393e

Browse files
authored
merge dev to main (0.2.0)
merge dev to main
2 parents c5d4ccd + ae41d65 commit 419393e

25 files changed

+3326
-0
lines changed

.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for more information:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://containers.dev/guide/dependabot
6+
7+
version: 2
8+
updates:
9+
- package-ecosystem: 'npm'
10+
directory: '/'
11+
schedule:
12+
interval: weekly
13+
target-branch: dev
14+
15+

.github/workflows/build-test.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build and Test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- dev
8+
9+
env:
10+
TELEMETRY_TRACKING_TOKEN: ${{ secrets.TELEMETRY_TRACKING_TOKEN }}
11+
DO_NOT_TRACK: "1"
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
build-test:
18+
runs-on: ubuntu-latest
19+
20+
strategy:
21+
matrix:
22+
node-version: [20.x]
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Install pnpm
29+
uses: pnpm/action-setup@v2
30+
with:
31+
version: 10.12.1
32+
33+
- name: Use Node.js ${{ matrix.node-version }}
34+
uses: buildjet/setup-node@v3
35+
with:
36+
node-version: ${{ matrix.node-version }}
37+
cache: "pnpm"
38+
39+
- name: Get pnpm store directory
40+
id: pnpm-cache
41+
shell: bash
42+
run: |
43+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
44+
45+
- name: Setup pnpm cache
46+
uses: buildjet/cache@v3
47+
with:
48+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
49+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
50+
restore-keys: |
51+
${{ runner.os }}-pnpm-store-
52+
53+
- name: Install dependencies
54+
run: pnpm install --frozen-lockfile
55+
56+
- name: Build
57+
run: |
58+
pnpm run build
59+
pnpm tsx scripts/post-build.ts
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Publish and Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
env:
9+
TELEMETRY_TRACKING_TOKEN: ${{ secrets.TELEMETRY_TRACKING_TOKEN }}
10+
DO_NOT_TRACK: "1"
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
publish-and-release:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Install pnpm
24+
uses: pnpm/action-setup@v2
25+
with:
26+
version: 10.12.1
27+
28+
- name: Use Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: 20.x
32+
cache: "pnpm"
33+
registry-url: "https://registry.npmjs.org"
34+
35+
- name: Install dependencies
36+
run: pnpm install --frozen-lockfile
37+
38+
- name: Build
39+
run: |
40+
pnpm run build
41+
pnpm tsx scripts/post-build.ts
42+
43+
- name: Get version from package.json
44+
id: version
45+
run: |
46+
VERSION=$(node -p "require('./package.json').version")
47+
echo "version=$VERSION" >> $GITHUB_OUTPUT
48+
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
49+
50+
- name: Publish packages
51+
run: pnpm run publish-all
52+
env:
53+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
54+
55+
- name: Generate changelog
56+
id: changelog
57+
run: |
58+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
59+
60+
if [ -z "$PREVIOUS_TAG" ]; then
61+
CHANGELOG=$(git log --oneline --no-merges --format="* %s" HEAD)
62+
else
63+
CHANGELOG=$(git log --oneline --no-merges --format="* %s" ${PREVIOUS_TAG}..HEAD)
64+
fi
65+
66+
if [ -z "$CHANGELOG" ]; then
67+
CHANGELOG="* Automated release"
68+
fi
69+
70+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
71+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
72+
echo "EOF" >> $GITHUB_OUTPUT
73+
74+
- name: Create GitHub Release
75+
uses: softprops/action-gh-release@v2
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
with:
79+
tag_name: ${{ steps.version.outputs.tag }}
80+
name: ZenStack Proxy Release ${{ steps.version.outputs.tag }}
81+
body: |
82+
## Changes in this release
83+
84+
${{ steps.changelog.outputs.changelog }}
85+
draft: true

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
build
3+
dist
4+
*.log
5+
.env
6+
.DS_Store
7+
*.tsbuildinfo

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.github/

.prettierrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 2,
4+
"semi": false,
5+
"singleQuote": true,
6+
"printWidth": 100,
7+
"endOfLine": "lf",
8+
"overrides": [
9+
{
10+
"files": "**/*.json",
11+
"options": { "parser": "json" }
12+
}
13+
]
14+
}

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# ZenStack Proxy CLI
2+
3+
A CLI tool to run an Express server with ZenStack proxy integration directly from the command line.
4+
5+
## Installation
6+
7+
```bash
8+
npm install @zenstackhq/proxy
9+
```
10+
11+
## Usage
12+
13+
### Start the Server
14+
15+
```bash
16+
zenstack-proxy [options]
17+
```
18+
19+
### Options
20+
21+
- `-z, --zenstack <path>` Path to ZenStack generated folder
22+
- `-p, --port <number>` Port number for the server (default: `8008`)
23+
- `-s, --schema <path>` - Path to ZModel schema file (default: "schema.zmodel")
24+
- `-d, --datasource-url <url>` Datasource URL (overrides schema configuration)
25+
- `-l, --log <level...>` Query log levels (e.g., query, info, warn, error)
26+
27+
### Examples
28+
29+
#### Basic Usage
30+
31+
Start a server with default settings (searches for ZenStack output automatically):
32+
33+
```bash
34+
zenstack-proxy
35+
```
36+
37+
#### Specify ZenStack schema and generated output
38+
39+
```bash
40+
zenstack-proxy -s ./schema/schema.zmodel -z ./generated/zenstack
41+
```
42+
43+
#### Custom Port
44+
45+
```bash
46+
zenstack-proxy -p 8888
47+
```
48+
49+
## Server Endpoints
50+
51+
The server provides the following endpoints:
52+
53+
### ZenStack Model API
54+
55+
- `POST /api/model/:model/:operation` - All ZenStack operations (find, create, update, delete, etc.)
56+
57+
The ZenStack middleware handles all CRUD operations for your models.
58+
59+
### Metadata
60+
61+
- `GET /api/schema` - Get complete schema metadata (models + enums)
62+
63+
## License
64+
65+
MIT

bin/cli.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
require('../index.js').default()

package.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "@zenstackhq/proxy",
3+
"version": "0.2.0",
4+
"description": "A CLI tool to run an Express server that proxies CRUD requests to a ZenStack backend",
5+
"main": "index.js",
6+
"publishConfig": {
7+
"directory": "dist",
8+
"linkDirectory": true
9+
},
10+
"bin": {
11+
"zenstack-proxy": "./bin/cli.js"
12+
},
13+
"scripts": {
14+
"clean": "rimraf dist",
15+
"build": "pnpm clean && tsc && copyfiles -F \"bin/*\" dist && copyfiles ./README.md ./LICENSE ./package.json dist && pnpm pack dist --pack-destination ../build",
16+
"prepublishOnly": "npm run build"
17+
},
18+
"keywords": ["zenstack", "proxy", "express", "cli"],
19+
"author": "",
20+
"license": "MIT",
21+
"dependencies": {
22+
"@prisma/adapter-better-sqlite3": "^6.2.1",
23+
"@prisma/adapter-mariadb": "^7.1.0",
24+
"@prisma/adapter-pg": "^6.18.0",
25+
"@zenstackhq/server": "^2.0.0",
26+
"colors": "^1.4.0",
27+
"commander": "^12.0.0",
28+
"cors": "^2.8.5",
29+
"dotenv": "^17.2.3",
30+
"express": "^4.19.2",
31+
"mixpanel": "^0.19.1",
32+
"semver": "^7.7.3",
33+
"tsx": "^4.20.6"
34+
},
35+
"devDependencies": {
36+
"@types/cors": "^2.8.17",
37+
"@types/express": "^5.0.0",
38+
"@types/node": "^20.0.0",
39+
"@types/semver": "^7.7.1",
40+
"copyfiles": "^2.4.1",
41+
"rimraf": "^4.0.0",
42+
"typescript": "^5.0.0"
43+
}
44+
}

0 commit comments

Comments
 (0)