dsh-github-console 0.2.5 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/assets/icon-180.png +0 -0
- package/assets/icon-512.png +0 -0
- package/assets/icon-96.png +0 -0
- package/client.js +404 -16
- package/cordis.patch.yml +3 -0
- package/icon.svg +4 -6
- package/index.js +1412 -22
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -27,6 +27,32 @@ DSH 的 GitHub 插件:在你自己的账号下注册一个私有 GitHub App,
|
|
|
27
27
|
|
|
28
28
|
为什么还要人工:npm 只允许给**已存在**的包配置 Trusted Publisher([npm docs](https://docs.npmjs.com/trusted-publishers/)),而且这台机器没有 npm,所以首次发布走「GitHub Actions + NPM_TOKEN」这条路;之后一律 OIDC,不再需要任何密钥。
|
|
29
29
|
|
|
30
|
+
## 安装方式(三选一,都不需要 npm)
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
# 1. git 方式(钉住提交,最稳)
|
|
34
|
+
dsh plugin add git+https://github.com/artbnjk/dsh-github-console.git#<commit>
|
|
35
|
+
|
|
36
|
+
# 2. Release 附件(下载 .tgz,解压后用 Plugins → Add plugin 指向目录)
|
|
37
|
+
# 固定名的资产:releases/latest/download/dsh-github-console.tgz
|
|
38
|
+
# 带版本号的资产:releases/download/v<版本>/dsh-github-console-<版本>.tgz
|
|
39
|
+
|
|
40
|
+
# 3. 自建市场索引:把索引地址加进 设置 → 插件 → 发现 / 市场源,然后一键安装
|
|
41
|
+
http://127.0.0.1:<DSH 端口>/github-console/market/index.json
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 图标与截图
|
|
45
|
+
|
|
46
|
+
- 插件图标:`icon.svg`(本插件的 Manifest 用 SVG,DSH 接受)。
|
|
47
|
+
- 位图图标:`assets/icon-512.png`、`icon-180.png`、`icon-96.png`,供商店卡片类列表使用(它们只收 GitHub 托管的 PNG/JPEG/WebP,拒收 SVG 与第三方图床)。
|
|
48
|
+
- 截图(可选):想控制商店里展示的顺序与内容,就在仓库里放 `screenshots.json`,列 1–8 张仓库内图片的相对路径;不放则回退到 README 里抽取的图片。
|
|
49
|
+
|
|
50
|
+
## 上架 dshmarket(awesome-dsh-plugin 列表)
|
|
51
|
+
|
|
52
|
+
那是**中央目录**:提 PR 到 `awesome-dsh-plugin/awesome-dsh-plugin`,一个 PR 最多 3 条,CI 会检查条目数、`dsh.bundle`、仓库年龄 ≥1 天、awesome-lint 与双语。面板里点「检查能否上 dshmarket」会把这几条逐项跑一遍,并给出可直接粘贴的条目字段(`url / name / category / icon / tarball`)。
|
|
53
|
+
|
|
54
|
+
与自建索引的区别:自建索引是**你自己的 JSON + git 源**,加进市场源立刻可见、无需审核;dshmarket 列表是**集中收录**,需要 PR 合并后才进目录(两种可以并存)。
|
|
55
|
+
|
|
30
56
|
## 自建市场索引(一键接入)
|
|
31
57
|
|
|
32
58
|
「市场」页两步:
|
|
@@ -59,6 +85,19 @@ manifest 的三步必须在 **1 小时**内完成,`state` 一次性、5 分钟
|
|
|
59
85
|
- 仓库/包里没有任何硬编码密钥;每个用户注册的是自己的 App。
|
|
60
86
|
- 撤销:面板「清除本地 App 凭据」删本机记录;App 本身到 GitHub → Settings → Applications 删除。
|
|
61
87
|
|
|
88
|
+
## 连接方式(三选一,面板里切换)
|
|
89
|
+
|
|
90
|
+
| 方式 | 怎么连 | 能做什么 | 代价 |
|
|
91
|
+
|---|---|---|---|
|
|
92
|
+
| **GitHub App**(默认) | 注册 → 安装 → 选 installation | 仓库读写、PR、Issue、Actions、Workflows、管理;**拿不到通知与代码搜索** | 1 小时安装令牌,最安全 |
|
|
93
|
+
| **个人访问令牌(PAT)** | 面板粘贴,存进凭据服务,只显示末四位 | 用户级能力全开(含通知、代码搜索、个人仓建仓) | 长期令牌,建议 fine-grained + 有效期 |
|
|
94
|
+
| **环境变量** | 配置 `patEnvName`(默认 `GITHUB_TOKEN`),值不落盘 | 同 PAT | 你自己管理变量 |
|
|
95
|
+
|
|
96
|
+
- 选择存进 `github-console/active`,切换不会丢另一种连接的凭据;`authMode` 可固定成 `app|pat|env`。
|
|
97
|
+
- 面板「状态 → 连接方式」显示**能力矩阵**(代码读写 / PR / Issue / Actions / Workflow / 管理 / 通知 / 代码搜索),灰度即代表当前连接做不到。
|
|
98
|
+
- **只读降级**:`readOnly: true`,或当前连接没有写权限时,所有写操作被拒绝并说明原因。
|
|
99
|
+
- **审计留痕**:写操作追加到 `$DSH_HOME/storages/dsh-github-console/audit.ndjson`(时间、动作、账号、目标、结果),可用 `gh_audit` 或面板查看。
|
|
100
|
+
|
|
62
101
|
## 发布一个插件
|
|
63
102
|
|
|
64
103
|
面板「发布」页填两样:本地插件目录(绝对路径或相对工作区)、目标 `owner/repo`(**仓库必须已存在**并授权给 App)。
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/client.js
CHANGED
|
@@ -240,6 +240,11 @@ window.__ModuleLoader__.load({
|
|
|
240
240
|
const [commitMessage, setCommitMessage] = useState('')
|
|
241
241
|
|
|
242
242
|
const [inbox, setInbox] = useState({ issues: null, pulls: null, runs: null, errors: [] })
|
|
243
|
+
const [pullDetail, setPullDetail] = useState(null)
|
|
244
|
+
const [commentDraft, setCommentDraft] = useState('')
|
|
245
|
+
const [reviewNote, setReviewNote] = useState('')
|
|
246
|
+
const [inlineTarget, setInlineTarget] = useState('')
|
|
247
|
+
const [runLog, setRunLog] = useState(null)
|
|
243
248
|
|
|
244
249
|
const [publishDir, setPublishDir] = useState('')
|
|
245
250
|
const [report, setReport] = useState(null)
|
|
@@ -250,10 +255,16 @@ window.__ModuleLoader__.load({
|
|
|
250
255
|
const [probe, setProbe] = useState(null)
|
|
251
256
|
const [npmRun, setNpmRun] = useState(null)
|
|
252
257
|
const [npmState, setNpmState] = useState(null)
|
|
258
|
+
const [releaseAsset, setReleaseAsset] = useState(null)
|
|
259
|
+
const [readiness, setReadiness] = useState(null)
|
|
253
260
|
const [marketIndex, setMarketIndex] = useState(null)
|
|
254
261
|
const [marketAttach, setMarketAttach] = useState(null)
|
|
255
262
|
const [reposLoaded, setReposLoaded] = useState(false)
|
|
256
263
|
const [reposTotal, setReposTotal] = useState(0)
|
|
264
|
+
const [patInput, setPatInput] = useState('')
|
|
265
|
+
const [authBusy, setAuthBusy] = useState('')
|
|
266
|
+
const [authMessage, setAuthMessage] = useState('')
|
|
267
|
+
const [device, setDevice] = useState(null)
|
|
257
268
|
const [setupUrl, setSetupUrl] = useState('')
|
|
258
269
|
const [discovered, setDiscovered] = useState(null)
|
|
259
270
|
const [discoverError, setDiscoverError] = useState('')
|
|
@@ -457,8 +468,78 @@ window.__ModuleLoader__.load({
|
|
|
457
468
|
})
|
|
458
469
|
}
|
|
459
470
|
|
|
460
|
-
const
|
|
461
|
-
const
|
|
471
|
+
const repoRef = () => {
|
|
472
|
+
const [owner, name] = String(selectedRepo || targetRepoFull()).split('/')
|
|
473
|
+
if (!owner || !name) {
|
|
474
|
+
setError('先选一个仓库(仓库页或发布页填写 owner/repo)')
|
|
475
|
+
return null
|
|
476
|
+
}
|
|
477
|
+
return { owner, name }
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
const openPull = (number) => {
|
|
481
|
+
const ref = repoRef()
|
|
482
|
+
if (!ref) return
|
|
483
|
+
void run('pull', async () => {
|
|
484
|
+
const detail = await api('pull/detail', { ...ref, number })
|
|
485
|
+
setPullDetail(detail)
|
|
486
|
+
setCommentDraft('')
|
|
487
|
+
setReviewNote('')
|
|
488
|
+
})
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
const sendPullComment = (inline) => {
|
|
492
|
+
const ref = repoRef()
|
|
493
|
+
if (!ref || !pullDetail) return
|
|
494
|
+
const body = inline ? inlineTarget.trim() : commentDraft.trim()
|
|
495
|
+
if (!body) {
|
|
496
|
+
setError('评论内容不能为空')
|
|
497
|
+
return
|
|
498
|
+
}
|
|
499
|
+
void run('comment', async () => {
|
|
500
|
+
const payload = { ...ref, number: pullDetail.number, body }
|
|
501
|
+
if (inline) {
|
|
502
|
+
const [path, line] = inline.split('#')
|
|
503
|
+
payload.path = path
|
|
504
|
+
payload.line = Number(line)
|
|
505
|
+
}
|
|
506
|
+
await api('pull/comment', payload)
|
|
507
|
+
if (inline) setInlineTarget('')
|
|
508
|
+
else setCommentDraft('')
|
|
509
|
+
const detail = await api('pull/detail', { ...ref, number: pullDetail.number })
|
|
510
|
+
setPullDetail(detail)
|
|
511
|
+
})
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
const sendReview = (event) => {
|
|
515
|
+
const ref = repoRef()
|
|
516
|
+
if (!ref || !pullDetail) return
|
|
517
|
+
void run('review', async () => {
|
|
518
|
+
await api('pull/review', { ...ref, number: pullDetail.number, event, body: reviewNote.trim() })
|
|
519
|
+
setReviewNote('')
|
|
520
|
+
const detail = await api('pull/detail', { ...ref, number: pullDetail.number })
|
|
521
|
+
setPullDetail(detail)
|
|
522
|
+
})
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
const toggleIssue = (item) => {
|
|
526
|
+
const ref = repoRef()
|
|
527
|
+
if (!ref) return
|
|
528
|
+
void run('issue', async () => {
|
|
529
|
+
await api('issue/update', { ...ref, number: item.number, state: item.state === 'open' ? 'closed' : 'open' })
|
|
530
|
+
loadInbox()
|
|
531
|
+
})
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
const showLog = (runId) => {
|
|
535
|
+
const ref = repoRef()
|
|
536
|
+
if (!ref) return
|
|
537
|
+
void run('log', async () => {
|
|
538
|
+
setRunLog(await api('actions/log', { ...ref, runId, tailLines: 80 }))
|
|
539
|
+
})
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
const runPreflight = async (dirOverride) => { const dir = dirOverride || publishDir
|
|
462
543
|
if (!String(dir).trim()) {
|
|
463
544
|
setError('先选一个插件目录:可以在上方「本地发现」里点体检,或在这里填绝对路径')
|
|
464
545
|
return undefined
|
|
@@ -570,6 +651,33 @@ window.__ModuleLoader__.load({
|
|
|
570
651
|
})
|
|
571
652
|
}
|
|
572
653
|
|
|
654
|
+
const checkReadiness = () => {
|
|
655
|
+
const owner = targetOwner
|
|
656
|
+
const repo = String(repoTarget).trim()
|
|
657
|
+
if (!owner || !repo) {
|
|
658
|
+
setError('先完成第 2 步并填好仓库名')
|
|
659
|
+
return
|
|
660
|
+
}
|
|
661
|
+
void run('readiness', async () => {
|
|
662
|
+
const result = await api('market/readiness', { dir: publishDir, owner, repo })
|
|
663
|
+
setReadiness(result)
|
|
664
|
+
return result
|
|
665
|
+
})
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
const makeReleaseAsset = () => { const owner = targetOwner
|
|
669
|
+
const repo = String(repoTarget).trim()
|
|
670
|
+
if (!owner || !repo) {
|
|
671
|
+
setError('先完成第 2 步并填好仓库名')
|
|
672
|
+
return
|
|
673
|
+
}
|
|
674
|
+
void run('asset', async () => {
|
|
675
|
+
const result = await api('release/asset', { dir: publishDir, owner, repo })
|
|
676
|
+
setReleaseAsset(result)
|
|
677
|
+
return result
|
|
678
|
+
})
|
|
679
|
+
}
|
|
680
|
+
|
|
573
681
|
const makeMarketIndex = () => { const owner = targetOwner
|
|
574
682
|
const repo = String(repoTarget).trim()
|
|
575
683
|
if (!owner || !repo) {
|
|
@@ -616,8 +724,90 @@ window.__ModuleLoader__.load({
|
|
|
616
724
|
return data
|
|
617
725
|
})
|
|
618
726
|
|
|
619
|
-
const
|
|
620
|
-
|
|
727
|
+
const useConnection = async (kind) => {
|
|
728
|
+
setAuthBusy(kind)
|
|
729
|
+
setAuthMessage('')
|
|
730
|
+
try {
|
|
731
|
+
await api('auth/use', { kind })
|
|
732
|
+
await refreshStatus()
|
|
733
|
+
setAuthMessage(`已切换到 ${kind}`)
|
|
734
|
+
} catch (failure) {
|
|
735
|
+
setAuthMessage(failure instanceof Error ? failure.message : String(failure))
|
|
736
|
+
} finally {
|
|
737
|
+
setAuthBusy('')
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
const savePat = async () => {
|
|
742
|
+
if (!patInput.trim()) {
|
|
743
|
+
setAuthMessage('先粘贴一个令牌')
|
|
744
|
+
return
|
|
745
|
+
}
|
|
746
|
+
setAuthBusy('pat')
|
|
747
|
+
setAuthMessage('')
|
|
748
|
+
try {
|
|
749
|
+
const result = await api('auth/pat', { token: patInput.trim() })
|
|
750
|
+
setPatInput('')
|
|
751
|
+
setAuthMessage(`已保存令牌(${result.login || '未知账号'} · ${result.fingerprint}),并设为当前连接`)
|
|
752
|
+
await refreshStatus()
|
|
753
|
+
} catch (failure) {
|
|
754
|
+
setAuthMessage(failure instanceof Error ? failure.message : String(failure))
|
|
755
|
+
} finally {
|
|
756
|
+
setAuthBusy('')
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
const clearPat = async () => {
|
|
761
|
+
setAuthBusy('pat-clear')
|
|
762
|
+
setAuthMessage('')
|
|
763
|
+
try {
|
|
764
|
+
await api('auth/pat/clear', {})
|
|
765
|
+
setAuthMessage('已删除本机保存的令牌')
|
|
766
|
+
await refreshStatus()
|
|
767
|
+
} catch (failure) {
|
|
768
|
+
setAuthMessage(failure instanceof Error ? failure.message : String(failure))
|
|
769
|
+
} finally {
|
|
770
|
+
setAuthBusy('')
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
// Device flow needs no callback URL, so it is independent of the web port.
|
|
775
|
+
const startDevice = async () => {
|
|
776
|
+
setAuthBusy('device')
|
|
777
|
+
setAuthMessage('')
|
|
778
|
+
try {
|
|
779
|
+
const started = await api('auth/device/start', {})
|
|
780
|
+
setDevice(started)
|
|
781
|
+
setAuthMessage(`在 ${started.verificationUri} 输入 ${started.userCode}(${Math.round(started.expiresIn / 60)} 分钟内有效)`)
|
|
782
|
+
const poll = async () => {
|
|
783
|
+
try {
|
|
784
|
+
const result = await api('auth/device/poll', { deviceCode: started.deviceCode })
|
|
785
|
+
if (result.status === 'ok') {
|
|
786
|
+
setDevice(null)
|
|
787
|
+
setAuthMessage('授权完成,已切换为「App 用户授权」:通知与代码搜索现在可用')
|
|
788
|
+
await refreshStatus()
|
|
789
|
+
return
|
|
790
|
+
}
|
|
791
|
+
if (result.status === 'expired' || result.status === 'denied') {
|
|
792
|
+
setDevice(null)
|
|
793
|
+
setAuthMessage(result.status === 'expired' ? '设备码已过期,请重新发起' : '授权被拒绝')
|
|
794
|
+
return
|
|
795
|
+
}
|
|
796
|
+
setTimeout(() => { void poll() }, result.slowDown ? 8000 : 5000)
|
|
797
|
+
} catch (failure) {
|
|
798
|
+
setDevice(null)
|
|
799
|
+
setAuthMessage(failure instanceof Error ? failure.message : String(failure))
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
setTimeout(() => { void poll() }, 5000)
|
|
803
|
+
} catch (failure) {
|
|
804
|
+
setAuthMessage(failure instanceof Error ? failure.message : String(failure))
|
|
805
|
+
} finally {
|
|
806
|
+
setAuthBusy('')
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
const installUrl = status && status.app && status.app.slug ? `https://github.com/apps/${status.app.slug}/installations/new`
|
|
621
811
|
: 'https://github.com/settings/installations'
|
|
622
812
|
|
|
623
813
|
// The saved installation may be gone (uninstalled on GitHub): compare it
|
|
@@ -629,6 +819,9 @@ window.__ModuleLoader__.load({
|
|
|
629
819
|
status && status.installation && liveIds.length > 0 && !liveIds.includes(String(status.installation.id)),
|
|
630
820
|
)
|
|
631
821
|
|
|
822
|
+
const authKind = status && status.auth ? status.auth.kind : 'none'
|
|
823
|
+
const authAccount = status && status.auth ? status.auth.account : ''
|
|
824
|
+
|
|
632
825
|
const badge = status && status.configured
|
|
633
826
|
? status.installation ? `已连接 ${status.installation.account}` : 'App 已注册,尚未安装'
|
|
634
827
|
: '未配置'
|
|
@@ -728,6 +921,110 @@ window.__ModuleLoader__.load({
|
|
|
728
921
|
? h('div', { style: S.warn }, status.network.hint)
|
|
729
922
|
: null,
|
|
730
923
|
),
|
|
924
|
+
h('div', { style: S.card },
|
|
925
|
+
h('div', { style: { ...S.line, justifyContent: 'space-between' } },
|
|
926
|
+
h('strong', { style: { fontSize: 13 } }, '连接方式'),
|
|
927
|
+
h('span', { style: S.badge(authKind === 'app' || authKind === 'pat' || authKind === 'env') },
|
|
928
|
+
{ app: 'GitHub App', pat: '个人访问令牌', env: '环境变量', none: '未连接' }[authKind] || authKind),
|
|
929
|
+
),
|
|
930
|
+
h('p', { style: S.notice }, `当前账号:${authAccount || '—'}${status && status.auth && status.auth.readOnly ? ' · 只读模式' : ''}`),
|
|
931
|
+
h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap', margin: '6px 0' } },
|
|
932
|
+
[['app', 'GitHub App'], ['oauth', 'App 用户授权'], ['pat', '个人访问令牌'], ['env', `环境变量(${status && status.connections ? status.connections.env.name : 'GITHUB_TOKEN'})`]].map(([kind, label]) =>
|
|
933
|
+
h('button', {
|
|
934
|
+
key: kind,
|
|
935
|
+
style: authKind === kind ? { ...S.primary, padding: '4px 12px', fontSize: 12 } : { ...S.button, padding: '4px 12px', fontSize: 12 },
|
|
936
|
+
disabled: authBusy === kind,
|
|
937
|
+
onClick: () => useConnection(kind),
|
|
938
|
+
}, label),
|
|
939
|
+
),
|
|
940
|
+
),
|
|
941
|
+
h('div', { style: { display: 'flex', gap: 6, marginTop: 4, flexWrap: 'wrap' } },
|
|
942
|
+
h('input', {
|
|
943
|
+
style: { ...S.input, flex: 1, minWidth: 200 },
|
|
944
|
+
type: 'password',
|
|
945
|
+
value: patInput,
|
|
946
|
+
placeholder: status && status.connections && status.connections.pat.configured ? `已保存 ${status.connections.pat.fingerprint}(粘贴新值可替换)` : '粘贴个人访问令牌(ghp_… / github_pat_…)',
|
|
947
|
+
onChange: (event) => setPatInput(event.target.value),
|
|
948
|
+
}),
|
|
949
|
+
h('button', { style: S.button, disabled: authBusy === 'pat', onClick: savePat }, authBusy === 'pat' ? '验证中…' : '保存令牌'),
|
|
950
|
+
status && status.connections && status.connections.pat.configured
|
|
951
|
+
? h('button', { style: S.danger, disabled: authBusy === 'pat-clear', onClick: clearPat }, '删除令牌')
|
|
952
|
+
: null,
|
|
953
|
+
),
|
|
954
|
+
h('p', { style: S.notice }, '令牌只写入 DSH 凭据服务,面板只显示末四位;环境变量方式不落盘。通知中心与代码搜索只有用户令牌能做,App 安装令牌做不到。'),
|
|
955
|
+
h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', marginTop: 4 } },
|
|
956
|
+
h('button', {
|
|
957
|
+
style: S.primary,
|
|
958
|
+
disabled: authBusy === 'device' || Boolean(device),
|
|
959
|
+
onClick: startDevice,
|
|
960
|
+
}, authBusy === 'device' ? '申请中…' : device ? `等待授权:${device.userCode}` : '设备码授权(推荐,无需回调地址)'),
|
|
961
|
+
h('button', {
|
|
962
|
+
style: S.button,
|
|
963
|
+
disabled: authBusy === 'oauth',
|
|
964
|
+
onClick: async () => {
|
|
965
|
+
setAuthBusy('oauth')
|
|
966
|
+
setAuthMessage('')
|
|
967
|
+
try {
|
|
968
|
+
const result = await api('auth/oauth/start', {})
|
|
969
|
+
window.open(result.url, '_blank', 'noreferrer')
|
|
970
|
+
setAuthMessage(
|
|
971
|
+
result.callbackRegistered
|
|
972
|
+
? '已打开 GitHub 授权页:同意后回来点「刷新状态」,再选「App 用户授权」。'
|
|
973
|
+
: `先在 App 设置里加这个回调地址再授权:${result.callbackUrl}`,
|
|
974
|
+
)
|
|
975
|
+
} catch (failure) {
|
|
976
|
+
setAuthMessage(failure instanceof Error ? failure.message : String(failure))
|
|
977
|
+
} finally {
|
|
978
|
+
setAuthBusy('')
|
|
979
|
+
}
|
|
980
|
+
},
|
|
981
|
+
}, authBusy === 'oauth' ? '打开中…' : '授权 App 用户身份(拿通知与代码搜索)'),
|
|
982
|
+
status && status.connections && status.connections.oauth && status.connections.oauth.configured
|
|
983
|
+
? h('button', {
|
|
984
|
+
style: S.danger,
|
|
985
|
+
onClick: async () => {
|
|
986
|
+
await api('auth/oauth/clear', {})
|
|
987
|
+
setAuthMessage('已删除用户授权')
|
|
988
|
+
await refreshStatus()
|
|
989
|
+
},
|
|
990
|
+
}, '撤销用户授权')
|
|
991
|
+
: null,
|
|
992
|
+
),
|
|
993
|
+
authMessage ? h('p', { style: S.notice }, authMessage) : null,
|
|
994
|
+
device
|
|
995
|
+
? h('p', { style: S.notice },
|
|
996
|
+
'在浏览器打开 ',
|
|
997
|
+
h('a', { href: device.verificationUri, target: '_blank', rel: 'noreferrer', style: { color: 'var(--dsw-alias-brand-primary)' } }, device.verificationUri),
|
|
998
|
+
',输入 ',
|
|
999
|
+
h(CopyValue, { value: device.userCode }),
|
|
1000
|
+
' 并确认。插件会自动轮询结果。',
|
|
1001
|
+
)
|
|
1002
|
+
: null,
|
|
1003
|
+
status && status.auth && status.auth.capabilities
|
|
1004
|
+
? h('div', { style: { marginTop: 6 } },
|
|
1005
|
+
h('div', { style: S.meta }, '当前连接的能力'),
|
|
1006
|
+
h('div', { style: { display: 'flex', gap: 10, flexWrap: 'wrap', marginTop: 4, fontSize: 12 } },
|
|
1007
|
+
[
|
|
1008
|
+
['repoRead', '代码读'],
|
|
1009
|
+
['repoWrite', '代码写'],
|
|
1010
|
+
['pullWrite', 'PR 写'],
|
|
1011
|
+
['issueWrite', 'Issue 写'],
|
|
1012
|
+
['actionsWrite', 'Actions'],
|
|
1013
|
+
['workflowsWrite', 'Workflow'],
|
|
1014
|
+
['adminWrite', '管理'],
|
|
1015
|
+
['notifications', '通知'],
|
|
1016
|
+
['codeSearch', '代码搜索'],
|
|
1017
|
+
].map(([key, label]) =>
|
|
1018
|
+
h('span', { key, style: { color: status.auth.capabilities[key] ? 'var(--dsw-alias-state-success-primary)' : 'var(--dsw-alias-label-secondary)' } },
|
|
1019
|
+
`${status.auth.capabilities[key] ? '✓' : '✕'} ${label}`),
|
|
1020
|
+
),
|
|
1021
|
+
),
|
|
1022
|
+
)
|
|
1023
|
+
: null,
|
|
1024
|
+
status && status.auth && status.auth.readOnly
|
|
1025
|
+
? h('p', { style: S.warn }, `只读:${status.auth.readOnlyReason || '当前连接没有写权限'}`)
|
|
1026
|
+
: null,
|
|
1027
|
+
),
|
|
731
1028
|
// Next-step card: exactly one primary action per state, so a user who
|
|
732
1029
|
// just registered is never told to register again.
|
|
733
1030
|
h('div', { style: S.card },
|
|
@@ -889,6 +1186,7 @@ window.__ModuleLoader__.load({
|
|
|
889
1186
|
h('span', { style: { ...S.meta, width: 46 } }, `#${item.number}`),
|
|
890
1187
|
h('span', { style: S.name }, item.title),
|
|
891
1188
|
h('span', { style: S.meta }, item.isPullRequest ? 'PR' : item.user),
|
|
1189
|
+
h('button', { style: { ...S.button, padding: '1px 8px', fontSize: 11 }, disabled: busy === 'issue', onClick: () => toggleIssue(item) }, item.state === 'open' ? '关闭' : '重开'),
|
|
892
1190
|
),
|
|
893
1191
|
),
|
|
894
1192
|
)
|
|
@@ -897,7 +1195,7 @@ window.__ModuleLoader__.load({
|
|
|
897
1195
|
? h('div', { style: S.card },
|
|
898
1196
|
h('strong', { style: { fontSize: 13 } }, `Pull requests (${inbox.pulls.returned})`),
|
|
899
1197
|
inbox.pulls.items.map((item) =>
|
|
900
|
-
h('div', { key: item.number, style: S.row },
|
|
1198
|
+
h('div', { key: item.number, style: { ...S.row, cursor: 'pointer' }, onClick: () => openPull(item.number) },
|
|
901
1199
|
h('span', { style: { ...S.meta, width: 46 } }, `#${item.number}`),
|
|
902
1200
|
h('span', { style: S.name }, item.title),
|
|
903
1201
|
h('span', { style: S.meta }, `${item.head} → ${item.base}`),
|
|
@@ -913,10 +1211,66 @@ window.__ModuleLoader__.load({
|
|
|
913
1211
|
h('span', { style: S.name }, item.name),
|
|
914
1212
|
h('span', { style: S.meta }, `${item.status}${item.conclusion ? ` / ${item.conclusion}` : ''}`),
|
|
915
1213
|
h('span', { style: S.meta }, item.branch || ''),
|
|
1214
|
+
h('button', { style: { ...S.button, padding: '1px 8px', fontSize: 11 }, disabled: busy === 'log', onClick: () => showLog(item.id) }, '日志'),
|
|
916
1215
|
),
|
|
917
1216
|
),
|
|
918
1217
|
)
|
|
919
1218
|
: null,
|
|
1219
|
+
runLog
|
|
1220
|
+
? h('div', { style: S.card },
|
|
1221
|
+
h('div', { style: { ...S.line, justifyContent: 'space-between' } },
|
|
1222
|
+
h('strong', { style: { fontSize: 13 } }, `日志 · ${runLog.name || runLog.runId}`),
|
|
1223
|
+
h('button', { style: { ...S.button, padding: '1px 8px', fontSize: 11 }, onClick: () => setRunLog(null) }, '关闭'),
|
|
1224
|
+
),
|
|
1225
|
+
h('pre', { style: S.pre }, runLog.tail),
|
|
1226
|
+
)
|
|
1227
|
+
: null,
|
|
1228
|
+
pullDetail
|
|
1229
|
+
? h('div', { style: S.card },
|
|
1230
|
+
h('div', { style: { ...S.line, justifyContent: 'space-between' } },
|
|
1231
|
+
h('strong', { style: { fontSize: 13 } }, `#${pullDetail.number} ${pullDetail.title}`),
|
|
1232
|
+
h('span', { style: S.badge(pullDetail.mergeableState === 'clean' || pullDetail.mergeable) }, `${pullDetail.state} · ${pullDetail.mergeableState || '?'}`),
|
|
1233
|
+
),
|
|
1234
|
+
h('div', { style: S.line }, h('span', { style: S.label }, '分支'), h('span', { style: S.value }, `${pullDetail.head} → ${pullDetail.base}`)),
|
|
1235
|
+
h('div', { style: S.line }, h('span', { style: S.label }, '变更'), h('span', { style: S.value }, `+${pullDetail.additions} / -${pullDetail.deletions} · ${pullDetail.changedFiles} 个文件`)),
|
|
1236
|
+
pullDetail.body ? h('pre', { style: S.pre }, pullDetail.body) : null,
|
|
1237
|
+
pullDetail.files.map((file) =>
|
|
1238
|
+
h('div', { key: file.path, style: { marginTop: 8 } },
|
|
1239
|
+
h('div', { style: { ...S.meta } }, `${file.path} · ${file.status} +${file.additions}/-${file.deletions} · 行内评论示例:`, h('code', null, `${file.path}#1`)),
|
|
1240
|
+
h('pre', { style: { ...S.pre, maxHeight: 220 } }, file.patch || '(二进制或过大,无 patch)'),
|
|
1241
|
+
),
|
|
1242
|
+
),
|
|
1243
|
+
h('div', { style: { display: 'flex', gap: 6, marginTop: 10, flexWrap: 'wrap' } },
|
|
1244
|
+
h('input', { style: { ...S.input, flex: 1, minWidth: 200 }, value: inlineTarget, placeholder: '行内评论:path#line,例如 src/index.js#42', onChange: (event) => setInlineTarget(event.target.value) }),
|
|
1245
|
+
h('button', { style: S.button, disabled: busy === 'comment', onClick: () => sendPullComment(true) }, '行内评论'),
|
|
1246
|
+
),
|
|
1247
|
+
h('div', { style: { display: 'flex', gap: 6, marginTop: 8, flexWrap: 'wrap' } },
|
|
1248
|
+
h('input', { style: { ...S.input, flex: 1, minWidth: 200 }, value: commentDraft, placeholder: '会话评论', onChange: (event) => setCommentDraft(event.target.value) }),
|
|
1249
|
+
h('button', { style: S.button, disabled: busy === 'comment', onClick: () => sendPullComment(false) }, '发表评论'),
|
|
1250
|
+
),
|
|
1251
|
+
h('div', { style: { display: 'flex', gap: 6, marginTop: 8, flexWrap: 'wrap' } },
|
|
1252
|
+
h('input', { style: { ...S.input, flex: 1, minWidth: 200 }, value: reviewNote, placeholder: 'review 说明(请求修改必填)', onChange: (event) => setReviewNote(event.target.value) }),
|
|
1253
|
+
h('button', { style: S.primary, disabled: busy === 'review', onClick: () => sendReview('APPROVE') }, '批准'),
|
|
1254
|
+
h('button', { style: S.button, disabled: busy === 'review', onClick: () => sendReview('REQUEST_CHANGES') }, '请求修改'),
|
|
1255
|
+
h('button', { style: S.button, disabled: busy === 'review', onClick: () => sendReview('COMMENT') }, '仅评论'),
|
|
1256
|
+
),
|
|
1257
|
+
h('div', { style: { display: 'flex', gap: 6, marginTop: 8, flexWrap: 'wrap' } },
|
|
1258
|
+
h('button', {
|
|
1259
|
+
style: S.danger,
|
|
1260
|
+
disabled: busy === 'merge',
|
|
1261
|
+
onClick: () => {
|
|
1262
|
+
if (!window.confirm(`合并 #${pullDetail.number}(squash)?`)) return
|
|
1263
|
+
void run('merge', async () => {
|
|
1264
|
+
const ref = repoRef()
|
|
1265
|
+
await api('pull/merge', { ...ref, number: pullDetail.number, method: 'squash', confirm: true })
|
|
1266
|
+
await openPull(pullDetail.number)
|
|
1267
|
+
})
|
|
1268
|
+
},
|
|
1269
|
+
}, '合并(squash)'),
|
|
1270
|
+
h('button', { style: { ...S.button, padding: '1px 8px', fontSize: 11 }, onClick: () => setPullDetail(null) }, '收起'),
|
|
1271
|
+
),
|
|
1272
|
+
)
|
|
1273
|
+
: null,
|
|
920
1274
|
)
|
|
921
1275
|
: null,
|
|
922
1276
|
|
|
@@ -977,7 +1331,7 @@ window.__ModuleLoader__.load({
|
|
|
977
1331
|
h('p', { style: S.notice }, `发布会在仓库上设置 ${status && status.publish ? status.publish.topic : 'dsh-plugin'} topic,供插件市场索引抓取。`),
|
|
978
1332
|
h('div', { style: { borderTop: '1px solid var(--dsw-alias-border-l1)', marginTop: 12, paddingTop: 10 } },
|
|
979
1333
|
h('div', { style: { ...S.line, justifyContent: 'space-between' } },
|
|
980
|
-
h('strong', { style: { fontSize: 12 } }, 'npm
|
|
1334
|
+
h('strong', { style: { fontSize: 12 } }, '可选:发到 npm(需要 npm 通行密钥)'),
|
|
981
1335
|
npmState ? h('span', { style: S.badge(npmState.phase === 'ready') }, NPM_PHASE[npmState.phase] || npmState.phase) : null,
|
|
982
1336
|
),
|
|
983
1337
|
h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', marginTop: 8 } },
|
|
@@ -992,7 +1346,8 @@ window.__ModuleLoader__.load({
|
|
|
992
1346
|
),
|
|
993
1347
|
npmState && npmState.phase === 'needs-first-publish'
|
|
994
1348
|
? h('div', null,
|
|
995
|
-
h('p', { style: S.
|
|
1349
|
+
h('p', { style: S.warn }, '如果 npm 要求通行密钥而你的手机/电脑连不上:跳过 npm,用上面的「分发(不需要 npm)」。npm 只是额外渠道,不是 DSH 插件的必需项。'),
|
|
1350
|
+
h('p', { style: S.notice }, '仍然想发 npm 的话,按顺序做:'),
|
|
996
1351
|
h('ol', { style: { ...S.notice, paddingLeft: 20, margin: '4px 0', lineHeight: 1.8 } },
|
|
997
1352
|
(npmState.steps || []).map((step, index) => h('li', { key: index }, step)),
|
|
998
1353
|
),
|
|
@@ -1044,6 +1399,40 @@ window.__ModuleLoader__.load({
|
|
|
1044
1399
|
),
|
|
1045
1400
|
h(PreflightView, { report }),
|
|
1046
1401
|
h(StepsView, { job }),
|
|
1402
|
+
h('div', { style: S.card },
|
|
1403
|
+
h('strong', { style: { fontSize: 13 } }, '分发(不需要 npm)'),
|
|
1404
|
+
h('p', { style: S.notice }, '把插件打包成 .tgz 挂到这次 Release 上,并给出钉住提交的 git 地址。Market 索引用的也是同一个 git 源,所以 Discover 安装同样不需要 npm。'),
|
|
1405
|
+
h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap' } },
|
|
1406
|
+
h('button', { style: S.primary, disabled: busy === 'asset' || !targetOwner, onClick: makeReleaseAsset }, busy === 'asset' ? '打包中…' : '打包并挂到 Release'),
|
|
1407
|
+
h('button', { style: S.button, disabled: busy === 'readiness' || !targetOwner, onClick: checkReadiness }, busy === 'readiness' ? '检查中…' : '检查能否上 dshmarket'),
|
|
1408
|
+
),
|
|
1409
|
+
readiness
|
|
1410
|
+
? h('div', { style: { marginTop: 8 } },
|
|
1411
|
+
h('div', { style: { ...S.line, justifyContent: 'space-between' } },
|
|
1412
|
+
h('strong', { style: { fontSize: 12 } }, readiness.ready ? '可以提交到 dshmarket 了' : '还有阻断项未满足'),
|
|
1413
|
+
h('span', { style: S.badge(readiness.ready) }, readiness.ready ? 'ready' : 'blocked'),
|
|
1414
|
+
),
|
|
1415
|
+
readiness.checks.map((item) =>
|
|
1416
|
+
h('div', { key: item.id, style: S.line },
|
|
1417
|
+
h('span', { style: { ...S.meta, width: 14, flex: '0 0 auto', color: item.level === 'block' ? 'var(--dsw-alias-state-error-primary)' : item.level === 'warn' ? 'var(--dsw-alias-state-warn-primary)' : 'var(--dsw-alias-label-secondary)' } }, item.level === 'pass' ? '✓' : item.level === 'block' ? '✕' : item.level === 'warn' ? '!' : '·'),
|
|
1418
|
+
h('span', { style: S.value }, item.title, item.detail ? h('span', { style: S.meta }, ` — ${item.detail}`) : null),
|
|
1419
|
+
),
|
|
1420
|
+
),
|
|
1421
|
+
readiness.entry && readiness.entry.tarball
|
|
1422
|
+
? h(CopyValue, { label: '条目字段 tarball:', value: readiness.entry.tarball })
|
|
1423
|
+
: null,
|
|
1424
|
+
)
|
|
1425
|
+
: null,
|
|
1426
|
+
releaseAsset
|
|
1427
|
+
? h('div', null,
|
|
1428
|
+
releaseAsset.asset && releaseAsset.asset.uploaded
|
|
1429
|
+
? h('p', { style: S.notice }, `已上传 ${releaseAsset.asset.name}(${Math.round(releaseAsset.asset.size / 1024)} KB):`,
|
|
1430
|
+
h('a', { href: releaseAsset.asset.url, target: '_blank', rel: 'noreferrer', style: { marginLeft: 6, color: 'var(--dsw-alias-brand-primary)' } }, '下载'))
|
|
1431
|
+
: h('p', { style: S.warn }, `上传失败:${releaseAsset.asset ? releaseAsset.asset.reason : '未知原因'}`),
|
|
1432
|
+
releaseAsset.gitInstall ? h(CopyValue, { label: 'git 安装地址:', value: releaseAsset.gitInstall }) : null,
|
|
1433
|
+
)
|
|
1434
|
+
: null,
|
|
1435
|
+
),
|
|
1047
1436
|
)
|
|
1048
1437
|
: null,
|
|
1049
1438
|
|
|
@@ -1116,12 +1505,10 @@ window.__ModuleLoader__.load({
|
|
|
1116
1505
|
return h(
|
|
1117
1506
|
'svg',
|
|
1118
1507
|
{ width: 16, height: 16, viewBox: '0 0 36 36', 'aria-hidden': true, style: { display: 'block', color: 'currentColor' } },
|
|
1119
|
-
h('g', { fill: '
|
|
1120
|
-
h('
|
|
1121
|
-
h('
|
|
1122
|
-
h('
|
|
1123
|
-
h('path', { d: 'M10 11.9v12.2' }),
|
|
1124
|
-
h('path', { d: 'M13.2 10.6c6 1.4 9.4 3.8 9.4 7.4' }),
|
|
1508
|
+
h('g', { fill: 'currentColor' },
|
|
1509
|
+
h('path', { d: 'M18 17.2 22.9 22.1 18 27 13.1 22.1Z' }),
|
|
1510
|
+
h('rect', { x: 16.6, y: 11.8, width: 2.8, height: 6.6, rx: 1 }),
|
|
1511
|
+
h('path', { d: 'M18 9.4 21.9 13.5 14.1 13.5Z' }),
|
|
1125
1512
|
),
|
|
1126
1513
|
)
|
|
1127
1514
|
}
|
|
@@ -1130,9 +1517,10 @@ window.__ModuleLoader__.load({
|
|
|
1130
1517
|
return h(
|
|
1131
1518
|
'svg',
|
|
1132
1519
|
{ width: 16, height: 16, viewBox: '0 0 36 36', 'aria-hidden': true, style: { display: 'block', color: 'currentColor' } },
|
|
1133
|
-
h('g', { fill: '
|
|
1134
|
-
h('
|
|
1135
|
-
h('
|
|
1520
|
+
h('g', { fill: 'currentColor' },
|
|
1521
|
+
h('path', { d: 'M18 17.2 22.9 22.1 18 27 13.1 22.1Z' }),
|
|
1522
|
+
h('rect', { x: 16.6, y: 11.8, width: 2.8, height: 6.6, rx: 1 }),
|
|
1523
|
+
h('path', { d: 'M18 9.4 21.9 13.5 14.1 13.5Z' }),
|
|
1136
1524
|
),
|
|
1137
1525
|
)
|
|
1138
1526
|
}
|
package/cordis.patch.yml
CHANGED
package/icon.svg
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36" role="img" aria-label="GitHub console">
|
|
2
|
-
<g fill="
|
|
3
|
-
<path d="
|
|
4
|
-
<
|
|
2
|
+
<g fill="#3E6FD8">
|
|
3
|
+
<path d="M18 17.2 22.9 22.1 18 27 13.1 22.1Z"/>
|
|
4
|
+
<rect x="16.6" y="11.8" width="2.8" height="6.6" rx="1"/>
|
|
5
|
+
<path d="M18 9.4 21.9 13.5 14.1 13.5Z"/>
|
|
5
6
|
</g>
|
|
6
|
-
<circle cx="11.2" cy="9.2" r="4.4" fill="#3E6FD8"/>
|
|
7
|
-
<circle cx="11.2" cy="26.8" r="4.4" fill="#3E6FD8"/>
|
|
8
|
-
<circle cx="26.4" cy="18.2" r="4" fill="#7BA4E3"/>
|
|
9
7
|
</svg>
|