mirror of
https://github.com/penpot/penpot.git
synced 2026-01-22 05:10:21 -05:00
Compare commits
1 Commits
niwinz-dev
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1335961b4 |
73
.github/workflows/plugins-deploy-api-doc.yml
vendored
Normal file
73
.github/workflows/plugins-deploy-api-doc.yml
vendored
Normal 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 }}
|
||||
@@ -75,25 +75,20 @@
|
||||
|
||||
#?(:cljs
|
||||
(defn ->clj
|
||||
[o & {:keys [key-fn val-fn recursive] :or {key-fn read-kebab-key val-fn identity recursive true}}]
|
||||
[o & {:keys [key-fn val-fn] :or {key-fn read-kebab-key val-fn identity}}]
|
||||
(let [f (fn this-fn [x]
|
||||
(let [x (val-fn x)]
|
||||
(cond
|
||||
(array? x)
|
||||
(persistent!
|
||||
(.reduce ^js/Array x
|
||||
#(conj! %1 (if recursive
|
||||
(this-fn %2)
|
||||
%2))
|
||||
#(conj! %1 (this-fn %2))
|
||||
(transient [])))
|
||||
|
||||
(identical? (type x) js/Object)
|
||||
(persistent!
|
||||
(.reduce ^js/Array (js-keys x)
|
||||
#(assoc! %1 (key-fn %2)
|
||||
(if recursive
|
||||
(this-fn (unchecked-get x %2))
|
||||
(unchecked-get x %2)))
|
||||
#(assoc! %1 (key-fn %2) (this-fn (unchecked-get x %2)))
|
||||
(transient {})))
|
||||
|
||||
:else
|
||||
|
||||
@@ -172,22 +172,6 @@
|
||||
schema-1 (c/get params :schema-1)
|
||||
this? (c/get params :this false)
|
||||
|
||||
decode-expr
|
||||
(c/get params :decode/fn)
|
||||
|
||||
decode-options
|
||||
(c/get params :decode/options)
|
||||
|
||||
decode-options
|
||||
(if (and decode-expr decode-options)
|
||||
(do
|
||||
(println "WARN: decode/fn and decode/options are excluding, ignoring decode/options")
|
||||
nil)
|
||||
decode-options)
|
||||
|
||||
decode-expr
|
||||
(or decode-expr 'app.common.json/->clj)
|
||||
|
||||
fn-sym
|
||||
(-> (gensym (str "internal-fn-" (str/slug pname) "-"))
|
||||
(with-meta {:tag 'function}))
|
||||
@@ -196,20 +180,9 @@
|
||||
(-> (gensym (str "coercer-fn-" (str/slug pname) "-"))
|
||||
(with-meta {:tag 'function}))
|
||||
|
||||
decode-sym
|
||||
(-> (gensym (str "decode-fn-" (str/slug pname) "-"))
|
||||
(with-meta {:tag 'function}))
|
||||
|
||||
schema-sym
|
||||
(-> (gensym (str "schema-" (str/slug pname) "-"))
|
||||
(with-meta {:tag 'function}))
|
||||
|
||||
wrap-sym
|
||||
(-> (gensym (str "wrap-fn-" (str/slug pname) "-"))
|
||||
(with-meta {:tag 'function}))
|
||||
|
||||
val-sym
|
||||
(gensym (str "val-" (str/slug pname) "-"))]
|
||||
(with-meta {:tag 'function}))]
|
||||
|
||||
(concat
|
||||
(when wrap
|
||||
@@ -225,66 +198,20 @@
|
||||
get-expr)])
|
||||
|
||||
(when set-expr
|
||||
(concat
|
||||
(when (and schema-n (not (list? schema-n)))
|
||||
[coercer-sym `(sm/coercer ~schema-n)])
|
||||
|
||||
(when (and schema-n (list? schema-n))
|
||||
[schema-sym schema-n])
|
||||
|
||||
[decode-sym decode-expr]
|
||||
|
||||
[(make-sym pname "set-fn")
|
||||
(if this?
|
||||
`(fn [~val-sym]
|
||||
(let [~@(if (and schema-n (list? schema-n))
|
||||
[schema-sym `(~schema-sym ~val-sym)
|
||||
coercer-sym `(sm/coercer ~schema-sym)]
|
||||
[])
|
||||
~this-sym (~'js* "this")
|
||||
~fn-sym ~set-expr
|
||||
~val-sym ~(if schema-n
|
||||
(if decode-expr
|
||||
`(~decode-sym ~val-sym)
|
||||
`(~decode-sym ~val-sym ~decode-options))
|
||||
val-sym)
|
||||
~val-sym ~(if schema-n
|
||||
`(~coercer-sym ~val-sym)
|
||||
val-sym)]
|
||||
(.call ~fn-sym ~this-sym ~this-sym ~val-sym)))
|
||||
`(fn [~val-sym]
|
||||
(let [~@(if (and schema-n (list? schema-n))
|
||||
[schema-sym `(~schema-sym ~val-sym)
|
||||
coercer-sym `(sm/coercer ~schema-sym)]
|
||||
[])
|
||||
~this-sym (~'js* "this")
|
||||
~fn-sym ~set-expr
|
||||
~val-sym ~(if schema-n
|
||||
(if decode-expr
|
||||
`(~decode-sym ~val-sym)
|
||||
`(~decode-sym ~val-sym ~decode-options))
|
||||
val-sym)
|
||||
~val-sym ~(if schema-n
|
||||
`(~coercer-sym ~val-sym)
|
||||
val-sym)]
|
||||
(.call ~fn-sym ~this-sym ~val-sym))))]))
|
||||
[(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
|
||||
(cond
|
||||
(and schema-n (not (list? schema-n)))
|
||||
[coercer-sym `(sm/coercer ~schema-n)]
|
||||
|
||||
(and schema-n (list? schema-n))
|
||||
[schema-sym schema-n]
|
||||
|
||||
(and schema-1 (not (list? schema-1)))
|
||||
[coercer-sym `(sm/coercer ~schema-1)]
|
||||
|
||||
(and schema-1 (list? schema-1))
|
||||
[schema-sym schema-1])
|
||||
|
||||
[decode-sym decode-expr]
|
||||
(when schema-1
|
||||
[coercer-sym `(sm/coercer ~schema-1)])
|
||||
(when schema-n
|
||||
[coercer-sym `(sm/coercer ~schema-n)])
|
||||
|
||||
[(make-sym pname "get-fn")
|
||||
`(fn []
|
||||
@@ -295,42 +222,17 @@
|
||||
`(.bind ~fn-sym ~this-sym))
|
||||
|
||||
~@(if schema-1
|
||||
[fn-sym `(fn* [~val-sym]
|
||||
(let [~val-sym
|
||||
~(if decode-expr
|
||||
`(~decode-sym ~val-sym)
|
||||
`(~decode-sym ~val-sym ~decode-options))
|
||||
|
||||
~@(if (or (and schema-n (list? schema-n))
|
||||
(and schema-1 (list? schema-1)))
|
||||
[schema-sym `(~schema-sym ~val-sym)
|
||||
coercer-sym `(sm/coercer ~schema-sym)]
|
||||
[])
|
||||
|
||||
~val-sym
|
||||
(~coercer-sym ~val-sym)]
|
||||
|
||||
(~fn-sym ~val-sym)))]
|
||||
[fn-sym `(fn* [param#]
|
||||
(let [param# (json/->clj param#)
|
||||
param# (~coercer-sym param#)]
|
||||
(~fn-sym param#)))]
|
||||
[])
|
||||
~@(if schema-n
|
||||
[fn-sym `(fn* []
|
||||
(let [~val-sym
|
||||
(into-array (cljs.core/js-arguments))
|
||||
|
||||
~val-sym
|
||||
~(if decode-expr
|
||||
`(~decode-sym ~val-sym)
|
||||
`(~decode-sym ~val-sym ~decode-options))
|
||||
|
||||
~@(if (or (and schema-n (list? schema-n))
|
||||
(and schema-1 (list? schema-1)))
|
||||
[schema-sym `(~schema-sym ~val-sym)
|
||||
coercer-sym `(sm/coercer ~schema-sym)]
|
||||
[])
|
||||
|
||||
~val-sym
|
||||
(~coercer-sym ~val-sym)]
|
||||
(apply ~fn-sym ~val-sym)))]
|
||||
(let [params# (into-array (cljs.core/js-arguments))
|
||||
params# (mfu/bean params#)
|
||||
params# (~coercer-sym params#)]
|
||||
(apply ~fn-sym params#)))]
|
||||
[])
|
||||
~@(if wrap
|
||||
[fn-sym `(~wrap-sym ~fn-sym)]
|
||||
|
||||
4
plugins/wrangle-penpot-plugins-api-doc.toml
Normal file
4
plugins/wrangle-penpot-plugins-api-doc.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
name = "penpot-plugins-api-doc"
|
||||
compatibility_date = "2025-01-01"
|
||||
|
||||
assets = { directory = "dist/doc" }
|
||||
Reference in New Issue
Block a user