Compare commits

..

1 Commits

Author SHA1 Message Date
David Barragán Merino
ae458cccd0 🔧 Deploy penpot api documentation 2026-01-21 18:40:59 +01:00
3 changed files with 86 additions and 27 deletions

View File

@@ -0,0 +1,73 @@
name: Plugins/api-doc deployer
on:
push:
branches:
- develop
- staging
- main
paths:
- "plugins/**"
- ".github/workflows/deploy-plugin-docs.yml"
- "wrangle-penpot-plugins-api-doc.toml"
workflow_dispatch:
inputs:
gh_ref:
description: 'Name of the branch or ref'
type: string
required: true
default: 'develop'
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: plugins
steps:
- name: Extract some useful variables
id: vars
run: |
echo "gh_ref=${{ inputs.gh_ref || github.ref_name }}" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ steps.vars.outputs.gh_ref }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: "pnpm"
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build docs
run: pnpm run build:doc
- name: Select Worker name
run: |
REF="${{ steps.vars.outputs.gh_ref }}"
case "$REF" in
main) echo "WORKER_NAME=penpot-plugins-api-doc-pro" >> $GITHUB_ENV ;;
staging) echo "WORKER_NAME=penpot-plugins-api-doc-pre" >> $GITHUB_ENV ;;
develop) echo "WORKER_NAME=penpot-plugins-api-doc-hourly" >> $GITHUB_ENV ;;
*) echo "Unsupported branch ${REF}" && exit 1 ;;
esac
- name: Deploy to Cloudflare Workers
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: deploy --config wrangle-penpot-plugins-api-doc.toml --name ${{ env.WORKER_NAME }}

View File

@@ -172,9 +172,6 @@
schema-1 (c/get params :schema-1)
this? (c/get params :this false)
decode-options
(c/get params :decode-options)
fn-sym
(-> (gensym (str "internal-fn-" (str/slug pname) "-"))
(with-meta {:tag 'function}))
@@ -201,28 +198,13 @@
get-expr)])
(when set-expr
(concat
(when schema-n
[coercer-sym `(sm/coercer ~schema-n)])
[(make-sym pname "set-fn")
(if this?
`(fn [~'v]
(let [~this-sym (~'js* "this")
~fn-sym ~set-expr
~'v (json/->clj ~'v ~decode-options)
~'v ~(if schema-n
`(~coercer-sym ~'v)
'v)]
(.call ~fn-sym ~this-sym ~this-sym ~'v)))
`(fn [~'v]
(let [~this-sym (~'js* "this")
~fn-sym ~set-expr
~'v (json/->clj ~'v ~decode-options)
~'v ~(if schema-n
`(~coercer-sym ~'v)
'v)]
(.call ~fn-sym ~this-sym ~'v))))]))
[(make-sym pname "set-fn")
(if this?
`(fn [v#]
(let [~this-sym (~'js* "this")
~fn-sym ~set-expr]
(.call ~fn-sym ~this-sym ~this-sym v#)))
set-expr)])
(when fn-expr
(concat
@@ -241,14 +223,14 @@
~@(if schema-1
[fn-sym `(fn* [param#]
(let [param# (json/->clj param# ~decode-options)
(let [param# (json/->clj param#)
param# (~coercer-sym param#)]
(~fn-sym param#)))]
[])
~@(if schema-n
[fn-sym `(fn* []
(let [params# (into-array (cljs.core/js-arguments))
params# (json/->clj params# ~decode-options)
params# (mfu/bean params#)
params# (~coercer-sym params#)]
(apply ~fn-sym params#)))]
[])

View File

@@ -0,0 +1,4 @@
name = "penpot-plugins-api-doc"
compatibility_date = "2025-01-01"
assets = { directory = "dist/doc" }