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
4 changes: 0 additions & 4 deletions .coderabbit.yaml

This file was deleted.

61 changes: 48 additions & 13 deletions .github/workflows/tests.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
name: CI Workflow
name: CI

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on: [pull_request]
on:
pull_request:
push:
branches:
- master

jobs:
build:
tests:
name: Tests / ${{ matrix.sdk }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['8.3']
php-version: ['8.5']
sdk: [
Android5Java17,
Android16Java17,
Expand Down Expand Up @@ -77,18 +82,13 @@ jobs:
docker --version
composer install

- name: Lint
if: matrix.sdk == 'Lint'
run: |
composer lint

- name: Run Tests
env:
UNITY_LICENSE: ${{ matrix.sdk == 'Unity2021' && secrets.UNITY_LICENSE || '' }}
run: |
composer test tests/${{ matrix.sdk }}Test.php
run: composer test tests/${{ matrix.sdk }}Test.php

lint:
name: Checks / Lint
runs-on: ubuntu-latest

steps:
Expand All @@ -98,7 +98,7 @@ jobs:
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: '8.3'
php-version: '8.5'
extensions: curl

- name: Install
Expand All @@ -107,7 +107,42 @@ jobs:
- name: Lint
run: composer lint

refactor:
name: Checks / Refactor
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: '8.5'
extensions: curl

- name: Install
run: composer install

- name: Run Rector
run: composer refactor:check

twig-lint:
name: Checks / Twig
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0

- name: Run djLint
run: uvx djlint templates/ --lint

max-line-length:
name: Checks / Twig line length
runs-on: ubuntu-latest

steps:
Expand All @@ -116,6 +151,6 @@ jobs:

- name: Make script executable
run: chmod +x ./.github/scripts/max-line-length.sh

- name: Check max lines
run: ./.github/scripts/max-line-length.sh . 1200 "*.twig"
31 changes: 0 additions & 31 deletions .github/workflows/djlint.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Appwrite SDK Build Validation
name: Validation

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: '8.3'
php-version: '8.5'
extensions: curl

- name: Install Composer Dependencies
Expand Down
24 changes: 13 additions & 11 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The script strips Twig expressions before running `npm install`/`bun install`, t

## Repository at a Glance

- **Purpose:** Generate Appwrite SDKs for ~16 languages from Swagger/OpenAPI specs using Twig templates
- **Purpose:** Generate Appwrite SDKs and tooling targets for 20+ languages/platforms from Swagger/OpenAPI specs using Twig templates
- **Language:** PHP (generator engine) + Twig (templates)
- **Entry point:** `example.php` — runs generation for all or a specific SDK
- **Output:** `examples/<lang>/` — checked-in generated SDK output for verification
Expand All @@ -59,7 +59,7 @@ examples/<lang>/ ← Generated SDK output (checked in for verificat
example.php ← Entry point: regenerates all SDKs from specs
```

**Supported SDKs:** PHP, Web, Node, CLI, Ruby, Python, Dart, Flutter, React Native, Go, Swift, Apple, DotNet, Android, Kotlin, GraphQL, Markdown, AgentSkills, CursorPlugin, ClaudePlugin, CodexPlugin
**Supported SDKs:** PHP, Web, Node, CLI, Ruby, Python, Dart, Flutter, React Native, Go, Swift, Apple, DotNet, Android, Kotlin, Unity, REST, GraphQL, Rust, AgentSkills, CursorPlugin, ClaudePlugin, CodexPlugin

## Primary Workflows

Expand All @@ -68,11 +68,12 @@ example.php ← Entry point: regenerates all SDKs from specs
1. Edit template(s) in `templates/<lang>/`
2. Regenerate:
```bash
docker run --rm -v $(pwd):/app -w /app php:8.3-cli php example.php <lang>
php example.php <lang>
```
3. Diff `examples/<lang>/` to verify the output is correct
4. Run linter:
4. Run linters and refactor check:
```bash
composer refactor:check
composer lint-twig
# or directly
uvx djLint templates/ --lint
Expand Down Expand Up @@ -116,7 +117,7 @@ public function getFiles(): array
3. Create `templates/newlang/` and add all Twig files
4. Register all template files in `getFiles()`
5. Add generation block to `example.php`
6. Generate: `docker run --rm -v $(pwd):/app -w /app php:8.3-cli php example.php newlang`
6. Generate: `php example.php newlang`
7. Inspect `examples/newlang/`

## File Reference Map
Expand All @@ -139,6 +140,7 @@ Pass as first argument to generate only that SDK:
| Argument | Language class | Output dir |
|----------|---------------|------------|
| `php` | PHP | `examples/php/` |
| `unity` | Unity | `examples/unity/` |
| `web` | Web | `examples/web/` |
| `node` | Node | `examples/node/` |
| `cli` | CLI | `examples/cli/` |
Expand All @@ -151,10 +153,11 @@ Pass as first argument to generate only that SDK:
| `swift` | Swift | `examples/swift/` |
| `apple` | Apple | `examples/apple/` |
| `dotnet` | DotNet | `examples/dotnet/` |
| `rest` | REST | `examples/REST/` |
| `android` | Android | `examples/android/` |
| `kotlin` | Kotlin | `examples/kotlin/` |
| `graphql` | GraphQL | `examples/graphql/` |
| `markdown` | Markdown | `examples/markdown/` |
| `rust` | Rust | `examples/rust/` |
| `agent-skills` | AgentSkills | `examples/agent-skills/` |
| `cursor-plugin` | CursorPlugin | `examples/cursor-plugin/` |
| `claude-plugin` | ClaudePlugin | `examples/claude-plugin/` |
Expand Down Expand Up @@ -186,19 +189,17 @@ Pass as first argument to generate only that SDK:
## Installing Dependencies

```bash
# With Composer installed locally
composer update --ignore-platform-reqs --optimize-autoloader --no-plugins --no-scripts --prefer-dist

# With Docker
docker run --rm -it -v "$(pwd)":/app composer update --ignore-platform-reqs --optimize-autoloader --no-plugins --no-scripts --prefer-dist
```

## Running Tests

```bash
docker run --rm -v $(pwd):$(pwd):rw -w $(pwd) php:8.3-cli-alpine vendor/bin/phpunit
vendor/bin/phpunit
```

If local PHP is missing, is not the required version, or has extension issues, use the matching PHP Docker image as a fallback for that command.

## Pre-Submit Checklist

Before submitting changes that touch templates or language classes:
Expand All @@ -207,5 +208,6 @@ Before submitting changes that touch templates or language classes:
- [ ] Inspected `examples/<lang>/` output looks correct
- [ ] Any new template files are listed in `getFiles()` of the language class
- [ ] Any new language class is added to `example.php`
- [ ] Rector check passes (`composer refactor:check`)
- [ ] Twig linter passes (`composer lint-twig`)
- [ ] If a parent language was modified, child SDKs were also checked
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ sdk-generator/blob/master/example.php:
Run the following command (make sure you have an updated docker version on your machine):

```bash
docker run --rm -v $(pwd):/app -w /app php:8.3-cli php example.php
docker run --rm -v $(pwd):/app -w /app php:8.5-cli php example.php
```

>Note: You can just add the new language next to the other languages in the `example.php` file. You don't need to rewrite the file completely.
Expand Down Expand Up @@ -277,7 +277,7 @@ Also in `.travis.yml` add new env `SDK=[Language]` so that travis will run a tes

Finally, you can run tests using:
```sh
docker run --rm -v $(pwd):$(pwd):rw -w $(pwd) -v /var/run/docker.sock:/var/run/docker.sock php:8.3-cli-alpine sh -c "apk add docker-cli && vendor/bin/phpunit"
docker run --rm -v $(pwd):$(pwd):rw -w $(pwd) -v /var/run/docker.sock:/var/run/docker.sock php:8.5-cli-alpine sh -c "apk add docker-cli && vendor/bin/phpunit"
```

## SDK Generator Interface
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ⚙️ Appwrite SDK Generator

[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
[![Twig Linting](https://github.com/appwrite/sdk-generator/actions/workflows/djlint.yml/badge.svg)](https://github.com/appwrite/sdk-generator/actions/workflows/djlint.yml)
[![CI](https://github.com/appwrite/sdk-generator/actions/workflows/ci.yml/badge.svg)](https://github.com/appwrite/sdk-generator/actions/workflows/ci.yml)
[![X Account](https://img.shields.io/badge/follow-@appwrite-000000?style=flat-square&logo=x&logoColor=white)](https://x.com/appwrite)
[![appwrite.io](https://img.shields.io/badge/appwrite-.io-f02e65?style=flat-square)](https://appwrite.io)

Expand Down Expand Up @@ -174,7 +174,6 @@ php example.php agent-skills
| CLI | `cli` | Node.js 20 and Bun 1.3.11 in CI | [NPM Coding Style] | NPM, Bun, native binaries | `examples/cli/` |
| REST examples | `rest` | N/A | Markdown | N/A | `examples/REST/` |
| GraphQL | `graphql` | N/A | GraphQL | N/A | `examples/graphql/` |
| Markdown docs | `markdown` | N/A | Markdown | N/A | `examples/markdown/` |
| Agent Skills | `agent-skills` | N/A | Markdown | N/A | `examples/agent-skills/` |
| Cursor Plugin | `cursor-plugin` | N/A | Markdown | N/A | `examples/cursor-plugin/` |
| Claude Plugin | `claude-plugin` | N/A | Markdown | N/A | `examples/claude-plugin/` |
Expand Down
36 changes: 23 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"name": "appwrite/sdk-generator",
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"description": "SDK generator for Appwrite APIs across multiple programming languages and platforms",
"type": "library",
"license": "MIT",
"minimum-stability": "dev",
"prefer-stable": true,
"authors": [
{
"name": "Eldad Fux",
Expand All @@ -15,33 +13,45 @@
"test": "vendor/bin/phpunit",
"lint": "vendor/bin/phpcs",
"format": "vendor/bin/phpcbf",
"lint-twig": "uvx djlint templates/ --lint"
"refactor": "vendor/bin/rector process",
"refactor:check": "vendor/bin/rector process --dry-run",
"lint-twig": "uvx djlint templates/ --lint",
"check": [
"@lint",
"@lint-twig",
"@refactor:check",
"@test"
]
},
"autoload": {
"psr-4": {
"Appwrite\\SDK\\": "src/SDK",
"Appwrite\\Spec\\": "src/Spec"
"Appwrite\\SDK\\": "src/SDK/",
"Appwrite\\Spec\\": "src/Spec/"
}
},
"autoload-dev": {
"psr-4": {"Tests\\": "tests"}
"psr-4": {
"Tests\\": "tests/"
}
},
"require": {
"php": ">=8.3",
"php": ">=8.5",
"ext-curl": "*",
"ext-mbstring": "*",
"ext-json": "*",
"twig/twig": "3.27.*",
"matthiasmullie/minify": "1.3.*"
"ext-mbstring": "*",
"matthiasmullie/minify": "1.3.*",
"twig/twig": "3.27.*"
},
"require-dev": {
"phpunit/phpunit": "11.*",
"brianium/paratest": "7.*",
"phpunit/phpunit": "11.*",
"rector/rector": "^2.4",
"squizlabs/php_codesniffer": "3.*"
},
"config": {
"sort-packages": true,
"platform": {
"php": "8.3"
"php": "8.5"
}
}
}
Loading
Loading