Skip to content

Commit 1afece0

Browse files
committed
feat: SvelteKit OpenAPI remote function generator CLI
- CLI tool that generates typed SvelteKit remote functions (query, command, form) from OpenAPI specs - Parses openapi-typescript output to extract API paths and HTTP methods - Generates .remote.ts files with full type safety via z.custom and openapi-fetch - Runtime createRemoteHandlers factory wraps openapi-fetch client with error handling - Supports --spec (URL/file) and --types-path (existing api.d.ts) workflows - File grouping by URL segment depth or single file output - Commander.js CLI with chalk/ora for colored progress output - --dry-run and --quiet flags for CI-friendly usage - Cross-platform support (Windows npx.cmd, path resolution) - 76 tests including Petstore integration tests (JSON + YAML) - CI workflow for PRs, release workflow for npm publish with GitHub Releases
1 parent a5596b1 commit 1afece0

21 files changed

Lines changed: 5668 additions & 1 deletion

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [20, 22, 24]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- uses: pnpm/action-setup@v4
21+
with:
22+
version: 9
23+
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
cache: pnpm
28+
29+
- run: pnpm install
30+
31+
- run: pnpm run build
32+
33+
- run: pnpm test

.github/workflows/release.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: "Release version (e.g. 1.2.3 or v1.2.3)"
11+
required: true
12+
type: string
13+
14+
permissions:
15+
contents: write
16+
id-token: write
17+
18+
jobs:
19+
preflight:
20+
name: Preflight
21+
runs-on: ubuntu-latest
22+
outputs:
23+
version: ${{ steps.meta.outputs.version }}
24+
tag: ${{ steps.meta.outputs.tag }}
25+
is_prerelease: ${{ steps.meta.outputs.is_prerelease }}
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- id: meta
30+
name: Resolve release version
31+
shell: bash
32+
env:
33+
INPUT_VERSION: ${{ github.event.inputs.version }}
34+
REF_NAME: ${{ github.ref_name }}
35+
EVENT_NAME: ${{ github.event_name }}
36+
run: |
37+
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
38+
raw="$INPUT_VERSION"
39+
else
40+
raw="$REF_NAME"
41+
fi
42+
43+
version="${raw#v}"
44+
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
45+
echo "Invalid release version: $raw" >&2
46+
exit 1
47+
fi
48+
49+
echo "version=$version" >> "$GITHUB_OUTPUT"
50+
echo "tag=v$version" >> "$GITHUB_OUTPUT"
51+
if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
52+
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
53+
else
54+
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
55+
fi
56+
57+
- uses: pnpm/action-setup@v4
58+
with:
59+
version: 9
60+
61+
- uses: actions/setup-node@v4
62+
with:
63+
node-version: 22
64+
cache: pnpm
65+
66+
- run: pnpm install
67+
- run: pnpm run build
68+
- run: pnpm test
69+
70+
publish:
71+
name: Publish to npm
72+
needs: preflight
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v4
76+
77+
- uses: pnpm/action-setup@v4
78+
with:
79+
version: 9
80+
81+
- uses: actions/setup-node@v4
82+
with:
83+
node-version: 22
84+
registry-url: https://registry.npmjs.org
85+
cache: pnpm
86+
87+
- run: pnpm install
88+
89+
- name: Set package version
90+
env:
91+
RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
92+
run: npm version "$RELEASE_VERSION" --no-git-tag-version
93+
94+
- run: pnpm run build
95+
96+
- name: Publish to npm
97+
env:
98+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
99+
IS_PRERELEASE: ${{ needs.preflight.outputs.is_prerelease }}
100+
run: |
101+
if [[ "$IS_PRERELEASE" == "true" ]]; then
102+
npm publish --provenance --access public --tag next
103+
else
104+
npm publish --provenance --access public
105+
fi
106+
107+
release:
108+
name: GitHub Release
109+
needs: [preflight, publish]
110+
runs-on: ubuntu-latest
111+
steps:
112+
- uses: actions/checkout@v4
113+
114+
- name: Create GitHub Release
115+
uses: softprops/action-gh-release@v2
116+
with:
117+
tag_name: ${{ needs.preflight.outputs.tag }}
118+
name: v${{ needs.preflight.outputs.version }}
119+
generate_release_notes: true
120+
prerelease: ${{ needs.preflight.outputs.is_prerelease }}
121+
122+
update-version:
123+
name: Update package.json version
124+
needs: [preflight, publish]
125+
runs-on: ubuntu-latest
126+
steps:
127+
- uses: actions/checkout@v4
128+
with:
129+
ref: main
130+
fetch-depth: 0
131+
132+
- name: Bump version in package.json
133+
env:
134+
RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
135+
RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
136+
run: |
137+
npm version "$RELEASE_VERSION" --no-git-tag-version
138+
139+
if git diff --quiet -- package.json; then
140+
echo "No version change needed."
141+
exit 0
142+
fi
143+
144+
git config user.name "github-actions[bot]"
145+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
146+
git add package.json
147+
git commit -m "chore(release): bump version to $RELEASE_TAG"
148+
git push origin HEAD:main

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
dist/
3+
.claude/
4+
*.tgz
5+
.DS_Store

.nvmrc

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

0 commit comments

Comments
 (0)