From 2e951a084ece37e928f34de5740ed5f402777fdb Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 11 Jan 2025 20:49:32 +0800 Subject: [PATCH] :sparkles: Editing release runner --- bun.lockb | Bin 306076 -> 306076 bytes package.json | 2 +- packages/sn/package.json | 2 +- packages/sn/src/matrix/release.ts | 7 ++ src/components/matrix/MaReleaseForm.tsx | 111 +++++++++++++++++++++++- 5 files changed, 117 insertions(+), 5 deletions(-) diff --git a/bun.lockb b/bun.lockb index 48a5fe251316c2f1a42648e693ce6db22e03cd9c..5541d0fd01bf8c6f390ebb4b9724805e71828a2a 100755 GIT binary patch delta 150 zcmV;H0BQf6*Akr95|Az+kU%)AYF1Rg)p0Zc*v%?KlndRA$nQ2ZAERKL68o;?u}OV delta 150 zcmV;H0BQf6*Akr95|Az+rgMI7nLs+ql-L)@lcQW7lPe1ushm=e=?dqBNnhf(u}A1--GNpAT3{KHie+1X!h!wVo;3m zKhjQwg3PC diff --git a/package.json b/package.json index 3d63f39..85f9a97 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "remark-parse": "^11.0.0", "remark-rehype": "^11.1.1", "sitemap": "^8.0.0", - "solar-js-sdk": "^0.1.2", + "solar-js-sdk": "^0.1.3", "unified": "^11.0.5", "zustand": "^5.0.3" }, diff --git a/packages/sn/package.json b/packages/sn/package.json index dca8ab9..d96a256 100644 --- a/packages/sn/package.json +++ b/packages/sn/package.json @@ -8,7 +8,7 @@ "name": "LittleSheep", "email": "littlesheep.code@hotmail.com" }, - "version": "0.1.2", + "version": "0.1.3", "tsup": { "entry": [ "src/index.ts" diff --git a/packages/sn/src/matrix/release.ts b/packages/sn/src/matrix/release.ts index c73ca9d..518404b 100644 --- a/packages/sn/src/matrix/release.ts +++ b/packages/sn/src/matrix/release.ts @@ -8,6 +8,7 @@ export interface MaRelease { channel: string assets: Record installers: Record + runners: Record product_id: number meta: MaReleaseMeta } @@ -39,3 +40,9 @@ export interface MaReleaseInstaller { script?: string patches: MaReleaseInstallerPatch[] } + +export interface MaReleaseRunner { + workdir?: string + script: string + label: string +} diff --git a/src/components/matrix/MaReleaseForm.tsx b/src/components/matrix/MaReleaseForm.tsx index 8adb27d..a13b009 100644 --- a/src/components/matrix/MaReleaseForm.tsx +++ b/src/components/matrix/MaReleaseForm.tsx @@ -16,7 +16,14 @@ import { import { useRouter } from 'next-nprogress-bar' import { useEffect, useState } from 'react' import { useForm } from 'react-hook-form' -import { MaProduct, MaRelease, MaReleaseAsset, MaReleaseInstaller, MaReleaseInstallerPatch } from 'solar-js-sdk' +import { + MaProduct, + MaRelease, + MaReleaseAsset, + MaReleaseInstaller, + MaReleaseInstallerPatch, + MaReleaseRunner, +} from 'solar-js-sdk' import MonacoEditor from '@monaco-editor/react' import ErrorIcon from '@mui/icons-material/Error' @@ -31,6 +38,7 @@ export interface MatrixReleaseForm { content: string assets: Record installers: Record + runners: Record attachments: string[] } @@ -64,12 +72,16 @@ export default function MaReleaseForm({ if (defaultValue?.installers) { setInstallers(Object.keys(defaultValue.installers).map((k) => ({ k, v: defaultValue.installers[k] }))) } + if (defaultValue?.runners) { + setRunners(Object.keys(defaultValue.runners).map((k) => ({ k, v: defaultValue.runners[k] }))) + } }, []) const router = useRouter() const [assets, setAssets] = useState<{ k: string; v: MaReleaseAsset }[]>([]) const [installers, setInstallers] = useState<{ k: string; v: MaReleaseInstaller }[]>([]) + const [runners, setRunners] = useState<{ k: string; v: MaReleaseRunner }[]>([]) function addAsset() { setAssets((val) => [...val, { k: '', v: { uri: '', contentType: '' } }]) @@ -79,6 +91,10 @@ export default function MaReleaseForm({ setInstallers((val) => [...val, { k: '', v: { workdir: '', script: '', patches: [] } }]) } + function addRunner() { + setRunners((val) => [...val, { k: '', v: { workdir: '', script: '', label: '' } }]) + } + const [error, setError] = useState(null) const [busy, setBusy] = useState(false) @@ -97,6 +113,7 @@ export default function MaReleaseForm({ ...data, assets: assets.reduce((a, { k, v }) => ({ ...a, [k]: v }), {}), installers: installers.reduce((a, { k, v }) => ({ ...a, [k]: v }), {}), + runners: runners.reduce((a, { k, v }) => ({ ...a, [k]: v }), {}), }) callback() } catch (err: any) { @@ -254,7 +271,7 @@ export default function MaReleaseForm({ `${p.action}:${p.glob}`).join('\n')} @@ -309,6 +326,94 @@ export default function MaReleaseForm({ + + Runners + + {runners.map(({ k, v }, idx) => ( + + + + + { + setRunners((data) => + data.map((ele, index) => (index == idx ? { k: val.target.value, v: ele.v } : ele)), + ) + }} + /> + + + { + setRunners((data) => + data.map((ele, index) => + index == idx ? { k: ele.k, v: { ...ele.v, workdir: val.target.value } } : ele, + ), + ) + }} + /> + + + { + setRunners((data) => data.filter((_, index) => index != idx)) + }} + > + + + + + { + setRunners((data) => + data.map((ele, index) => + index == idx ? { k: ele.k, v: { ...ele.v, label: val.target.value } } : ele, + ), + ) + }} + /> + + + + Script + + + + setRunners((data) => + data.map((ele, index) => + index == idx ? { v: { ...ele.v, script: val ?? '' }, k: ele.k } : ele, + ), + ) + } + /> + + + + + + ))} + + + + + +