dsh-go-plugin-sync 0.4.3 → 0.4.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.5 — 2026-12-05
4
+
5
+ ### 文档
6
+ - README 说明:Git 仓库中转同步、SSH 直连同步处于测试阶段;本产品最初是为「用复制码快速同步双端可兼容的插件」而设计,Git 中转与 SSH 是后来补充的高级通道
7
+ - 同步更新 npm 页面展示的说明(README 随包发布)
8
+
9
+ ## 0.4.4 — 2026-12-04
10
+
11
+ ### 改进
12
+ - dsh-go 面板:「显示全部 / 只看待处理」从主按钮排移到列表下方、复制同步码上方,避免和主操作挤在一行
13
+ - dsh-go 面板补上「配置 Git 仓库」「配置 SSH」两个入口,各带一张表单(仓库地址/分支/目录;主机/端口/用户/私钥/远端 HOME),保存到同一份 plugin-sync-config.json;留空字段保持原值
14
+ - 文案统一(两端):「应用所选 / 执行选中」改为「下载并安装」,「重置清单 / 清空列表」改为「重置插件列表」,「重试失败」改为「重试失败项」,使用引导的步骤说明同步更新
15
+
3
16
  ## 0.4.3 — 2026-12-04
4
17
 
5
18
  ### 改进
package/README.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  同步只增不删:不会卸载或覆盖你已经有的插件;版本对不上、缺少文件、本机多出来的插件只做标记提醒,不自动处理。
6
6
 
7
+ > **测试阶段**:Git 仓库中转同步、SSH 直连同步目前仍处于测试阶段,接口和行为可能调整;日常快速同步请优先使用复制码。
8
+ >
9
+ > **产品定位**:本产品最初就是为「用复制码快速同步双端可兼容的插件」而设计的;Git 中转和 SSH 是后来补充的高级通道,不是主线。
10
+
7
11
  ## 功能
8
12
 
9
13
  - **同步码**:面板里复制,另一台主机粘贴导入
@@ -11,7 +15,7 @@
11
15
  - **部分选择 / 全选**:导入后默认选中同步码里的插件,可以手动取消或加选
12
16
  - **逐项结果**:每个插件的成功/失败都会列出来,失败项带报错尾巴,可一键重试
13
17
  - **状态条**:输入框上方显示「待同步 N 项 / 同步失败 N 项 / 插件已同步」
14
- - **高级通道**:Git 私有仓中转、SSH 直连(推送 / 拉取 / 拉远端清单)
18
+ - **高级通道(测试阶段)**:Git 私有仓中转、SSH 直连(推送 / 拉取 / 拉远端清单)
15
19
  - **使用引导**:面板里的「使用引导」有完整步骤
16
20
  - **电脑端设置页**:设置 → 插件同步,导入同步码、勾选安装、配置 Git 中转和 SSH
17
21
 
@@ -38,7 +42,7 @@ dsh plugin --profile web add ./dshgochajiantongbucha
38
42
  1. 在 A 主机打开「插件同步」,选中要同步的插件(或全选),点**复制同步码**
39
43
  2. 到 B 主机打开「插件同步」,把同步码粘进输入框,点**导入同步码**
40
44
  3. 列表会默认选中同步码里的插件;不需要的可以点掉
41
- 4. 点确认框的**应用所选**,后台开始安装
45
+ 4. 点确认框的**下载并安装**,后台开始安装
42
46
  5. 面板会显示逐项结果;失败项点**重试失败项**
43
47
  6. 装完后重启一次引擎让新插件加载
44
48
 
@@ -50,7 +54,7 @@ dsh plugin --profile web add ./dshgochajiantongbucha
50
54
 
51
55
  1. 粘贴同步码,点**导入同步码**
52
56
  2. 在插件列表里勾选要安装的项(默认选中同步码里的插件)
53
- 3. 点**安装选中**,下方显示任务状态
57
+ 3. 点**下载并安装**,下方显示任务状态
54
58
  4. 在同一页填写 **Git 中转**(仓库地址 / 分支 / 目录)和 **SSH**(主机 / 端口 / 用户 / 私钥 / profile),点**保存配置**
55
59
 
56
60
  Windows 上支持同步码导入和安装;安装任务由 Node 直接执行,不依赖 `/bin/sh`。Git 中转和 SSH 推/拉暂不支持 Windows。
@@ -147,3 +151,7 @@ other, and missing plugins install automatically.
147
151
  Add-only: it never uninstalls or overwrites existing plugins. Conflicts and
148
152
  missing files are reported as warnings. Advanced transports: a private Git relay
149
153
  or direct SSH.
154
+
155
+ **Status note:** the Git relay and SSH sync channels are still in testing and may
156
+ change. The product was originally designed for fast sync-code transfer of
157
+ plugins that work on both phone and desktop — prefer sync codes for everyday use.
package/lib/client.js CHANGED
@@ -185,12 +185,12 @@ window.__ModuleLoader__.load({
185
185
  }).catch((error) => { setBusy(false); note(String(error && error.message || error), 'bad') })
186
186
  }
187
187
  const clearList = () => {
188
- if (!window.confirm(T('清空待处理插件列表?导入新的同步码后会恢复。', 'Clear the pending list? Import a new sync code to restore it.'))) return
188
+ if (!window.confirm(T('重置插件列表?导入新的同步码后会恢复。', 'Reset the plugin list? Import a new sync code to restore it.'))) return
189
189
  setBusy(true)
190
190
  api('action', { action: 'clear' }).then((result) => {
191
191
  setBusy(false)
192
192
  if (result.error) { note(result.error, 'bad'); return }
193
- note(T('列表已清空', 'List cleared'), 'good')
193
+ note(T('已重置插件列表', 'Plugin list reset'), 'good')
194
194
  load()
195
195
  }).catch((error) => { setBusy(false); note(String(error && error.message || error), 'bad') })
196
196
  }
@@ -295,7 +295,7 @@ window.__ModuleLoader__.load({
295
295
  h('button', { type: 'button', style: BUTTON, disabled: busy, onClick: load }, T('刷新', 'Refresh')))),
296
296
 
297
297
  cleared && h('div', { style: { fontSize: '12px', opacity: 0.6 } },
298
- T('待处理列表已清空,重新导入同步码后会恢复。', 'The pending list was cleared. Import a new sync code to restore it.')),
298
+ T('插件列表已重置,重新导入同步码后会恢复。', 'The plugin list was reset. Import a new sync code to restore it.')),
299
299
 
300
300
  pendingRows.length > 0 && h('div', { style: { display: 'flex', flexDirection: 'column', gap: '4px' } },
301
301
  h('div', { style: { fontWeight: 600 } }, T('待处理插件', 'Pending plugins')),
@@ -303,8 +303,8 @@ window.__ModuleLoader__.load({
303
303
  h('div', { style: { display: 'flex', gap: '8px', marginTop: '4px', flexWrap: 'wrap' } },
304
304
  h('button', { type: 'button', style: BUTTON, onClick: () => all(true) }, T('全选', 'Select all')),
305
305
  h('button', { type: 'button', style: BUTTON, onClick: () => all(false) }, T('取消全选', 'Deselect all')),
306
- h('button', { type: 'button', style: PRIMARY, disabled: busy || running, onClick: applySelected }, T('执行选中', 'Run selected')),
307
- h('button', { type: 'button', style: BUTTON, disabled: busy || running, onClick: clearList }, T('清空列表', 'Clear list')))),
306
+ h('button', { type: 'button', style: PRIMARY, disabled: busy || running, onClick: applySelected }, T('下载并安装', 'Download & install')),
307
+ h('button', { type: 'button', style: BUTTON, disabled: busy || running, onClick: clearList }, T('重置插件列表', 'Reset plugin list')))),
308
308
 
309
309
  installedRows.length > 0 && h('details', { style: { fontSize: '13px' } },
310
310
  h('summary', { style: { cursor: 'pointer', opacity: 0.7 } },
package/lib/index.js CHANGED
@@ -1473,7 +1473,7 @@ function statusTone(status) {
1473
1473
  }
1474
1474
 
1475
1475
  const TASK_LABELS = {
1476
- apply: ['应用所选', 'apply selected'],
1476
+ apply: ['下载并安装', 'download & install'],
1477
1477
  'relay-push': ['推送中转', 'push to relay'],
1478
1478
  'relay-pull': ['拉取中转', 'pull from relay'],
1479
1479
  'ssh-test': ['测试 SSH', 'test SSH'],
@@ -1528,6 +1528,11 @@ function buildView(scope, caps, ctx) {
1528
1528
  [en ? 'SSH' : 'SSH', cfg.ssh.host ? `${cfg.ssh.user ? `${cfg.ssh.user}@` : ''}${cfg.ssh.host}:${cfg.ssh.port}` : (en ? 'not configured' : '未配置')],
1529
1529
  ] })
1530
1530
 
1531
+ children.push({ type: 'actions', items: [
1532
+ { label: en ? 'Configure Git relay' : '配置 Git 仓库', action: 'open-relay-config' },
1533
+ { label: en ? 'Configure SSH' : '配置 SSH', action: 'open-ssh-config' },
1534
+ ] })
1535
+
1531
1536
  const task = readTaskStatus()
1532
1537
  if (task?.running) {
1533
1538
  const stale = Date.now() - task.startedAt > 15 * 60 * 1000
@@ -1631,24 +1636,29 @@ function buildView(scope, caps, ctx) {
1631
1636
  : local.map((plugin) => plugin.name)
1632
1637
  const allSelected = selectableNames.length > 0 && selectableNames.every((name) => state.selected.has(name))
1633
1638
 
1639
+ if (state.manifest) {
1640
+ children.push({ type: 'actions', items: [
1641
+ { label: state.showAll ? (en ? 'Pending only' : '只看待处理') : (en ? 'Show all' : '显示全部'), action: 'toggle-show-all' },
1642
+ ] })
1643
+ }
1644
+
1634
1645
  const primary = [
1635
1646
  ...(task?.running ? [{ label: en ? 'Stop task' : '取消任务', action: 'stop-task' }] : []),
1636
1647
  { label: en ? 'Copy code' : '复制同步码', action: 'copy-code' },
1637
1648
  { label: allSelected ? (en ? 'Select none' : '取消全选') : (en ? 'Select all' : '全选'), action: allSelected ? 'clear' : 'select-all' },
1638
- { label: state.showAll ? (en ? 'Pending only' : '只看待处理') : (en ? 'Show all' : '显示全部'), action: 'toggle-show-all' },
1639
1649
  { label: en ? 'Refresh' : '刷新', action: 'refresh' },
1640
1650
  ]
1641
1651
  children.push({ type: 'actions', items: primary })
1642
1652
 
1643
1653
  const failedCount = results.filter((result) => !result.ok).length
1644
1654
  const secondary = []
1645
- if (failedCount > 0) secondary.push({ label: en ? `Retry failed (${failedCount})` : `重试失败(${failedCount})`, action: 'retry-failed' })
1646
- secondary.push({ label: en ? 'Reset list' : '重置清单', action: 'clear-all' })
1655
+ if (failedCount > 0) secondary.push({ label: en ? `Retry failed (${failedCount})` : `重试失败项(${failedCount})`, action: 'retry-failed' })
1656
+ secondary.push({ label: en ? 'Reset plugin list' : '重置插件列表', action: 'clear-all' })
1647
1657
  secondary.push({ label: en ? 'Guide' : '使用引导', action: 'guide' })
1648
1658
  children.push({ type: 'actions', items: secondary })
1649
1659
 
1650
1660
  if (state.manifest && state.selected.size > 0) {
1651
- children.push({ type: 'confirm', id: 'apply', confirmLabel: en ? 'Apply' : '应用所选', cancelLabel: en ? 'Cancel' : '取消' })
1661
+ children.push({ type: 'confirm', id: 'apply', confirmLabel: en ? 'Download & install' : '下载并安装', cancelLabel: en ? 'Cancel' : '取消' })
1652
1662
  }
1653
1663
 
1654
1664
  const log = readLogTail(8)
@@ -1685,11 +1695,11 @@ function buildGuide(scope, caps, ctx) {
1685
1695
  { label: en ? 'Paste and import on B' : '在 B 粘贴并导入', status: 'current', detail: en
1686
1696
  ? 'Panel → code field → Import code'
1687
1697
  : '面板「同步码」输入框 → 导入同步码' },
1688
- { label: en ? 'Select and apply on B' : '在 B 选中并应用', status: 'todo', detail: en
1689
- ? 'All selected by default; deselect what you do not want'
1690
- : '默认全选,可取消不要的项' },
1698
+ { label: en ? 'Select and download' : '在 B 选中并下载安装', status: 'todo', detail: en
1699
+ ? 'Only double-end plugins missing here are preselected; adjust as needed'
1700
+ : '默认只勾选双端兼容且本机没有的插件,可再调整' },
1691
1701
  { label: en ? 'Retry failures' : '失败项点重试', status: 'todo', detail: en
1692
- ? 'Retry failed in the panel'
1702
+ ? 'Retry failed items in the panel'
1693
1703
  : '面板「重试失败项」' },
1694
1704
  { label: en ? 'Restart the engine' : '重启一次引擎', status: 'todo' },
1695
1705
  ] },
@@ -1802,6 +1812,12 @@ function configPathFor(ctx, scope) {
1802
1812
  return join(storeDir(), CONFIG_FILE)
1803
1813
  }
1804
1814
 
1815
+ function writeConfig(ctx, scope, cfg) {
1816
+ const target = configPathFor(ctx, scope)
1817
+ mkdirSync(dirname(target), { recursive: true })
1818
+ writeFileSync(target, JSON.stringify(normalizeConfig(cfg), null, 2) + '\n')
1819
+ }
1820
+
1805
1821
  // ---------------------------------------------------------------- plugin
1806
1822
 
1807
1823
  export function apply(ctx) {
@@ -2009,6 +2025,14 @@ export function apply(ctx) {
2009
2025
  return { refresh: true }
2010
2026
  },
2011
2027
 
2028
+ 'open-relay-config'() {
2029
+ return { open: 'panel:relay-config' }
2030
+ },
2031
+
2032
+ 'open-ssh-config'() {
2033
+ return { open: 'panel:ssh-config' }
2034
+ },
2035
+
2012
2036
  'clear-all'(scope) {
2013
2037
  const state = stateFor(scope)
2014
2038
  state.manifest = null
@@ -2017,7 +2041,7 @@ export function apply(ctx) {
2017
2041
  state.importedAt = null
2018
2042
  state.selected.clear()
2019
2043
  try { unlinkSync(importFile()) } catch {}
2020
- return [{ toast: '已清空清单,可重新导入同步码或拉取中转' }, { refresh: true }]
2044
+ return [{ toast: '已重置插件列表,可重新导入同步码或拉取中转' }, { refresh: true }]
2021
2045
  },
2022
2046
 
2023
2047
  guide() {
@@ -2070,6 +2094,123 @@ export function apply(ctx) {
2070
2094
  },
2071
2095
  })
2072
2096
 
2097
+ ctx.dshGo.panel('relay-config', {
2098
+ view(scope, caps) {
2099
+ const en = enableText(caps)
2100
+ const cfg = loadConfig(ctx, scope)
2101
+ const components = Array.isArray(caps?.components) ? caps.components : []
2102
+ const canForm = components.includes('form') && components.includes('textField')
2103
+ const children = [{
2104
+ type: 'text',
2105
+ text: en
2106
+ ? (cfg.relay.repo ? `Current: ${cfg.relay.repo} · ${cfg.relay.branch} · ${cfg.relay.dir}` : 'No Git relay configured yet.')
2107
+ : (cfg.relay.repo ? `当前:${cfg.relay.repo} · 分支 ${cfg.relay.branch} · 目录 ${cfg.relay.dir}` : '还没有配置 Git 中转仓。'),
2108
+ }]
2109
+ if (canForm) {
2110
+ children.push({ type: 'form', submit: 'save-relay', submitLabel: en ? 'Save' : '保存', children: [
2111
+ { type: 'textField', label: en ? 'Repository URL' : '仓库地址', bind: 'data.relay.repo', placeholder: 'https://gitee.com/you/dsh-plugins.git' },
2112
+ { type: 'textField', label: en ? 'Branch' : '分支', bind: 'data.relay.branch', placeholder: cfg.relay.branch },
2113
+ { type: 'textField', label: en ? 'Directory' : '目录', bind: 'data.relay.dir', placeholder: cfg.relay.dir },
2114
+ ] })
2115
+ } else {
2116
+ children.push({ type: 'callout', tone: 'info', text: en
2117
+ ? 'This app version has no panel input; configure it on the desktop settings page.'
2118
+ : '当前 App 版本不支持面板输入,请用电脑端设置页配置。' })
2119
+ }
2120
+ children.push({ type: 'callout', tone: 'info', text: en
2121
+ ? 'Git uses system credentials. Fields left empty keep their current value.'
2122
+ : 'Git 用系统凭据;留空的字段保持原值。' })
2123
+ const view = { type: 'stack', title: en ? 'Configure Git relay' : '配置 Git 仓库', children }
2124
+ if (canForm) view.v = 2
2125
+ return view
2126
+ },
2127
+ data(scope, emit) {
2128
+ emit({ relay: { repo: '', branch: '', dir: '' } })
2129
+ return () => {}
2130
+ },
2131
+ actions: {
2132
+ 'save-relay'(scope, event) {
2133
+ const values = event?.value?.values && typeof event.value.values === 'object' ? event.value.values : {}
2134
+ const pick = (key) => (typeof values[key] === 'string' ? values[key].trim() : '')
2135
+ const cfg = loadConfig(ctx, scope)
2136
+ const next = {
2137
+ relay: {
2138
+ repo: pick('data.relay.repo') || cfg.relay.repo,
2139
+ branch: pick('data.relay.branch') || cfg.relay.branch,
2140
+ dir: pick('data.relay.dir') || cfg.relay.dir,
2141
+ },
2142
+ ssh: cfg.ssh,
2143
+ }
2144
+ try { writeConfig(ctx, scope, next) } catch { return { toast: '保存失败,检查工作区权限' } }
2145
+ return [{ toast: '已保存 Git 仓库配置' }, { open: 'panel:sync' }]
2146
+ },
2147
+ back() {
2148
+ return { open: 'panel:sync' }
2149
+ },
2150
+ },
2151
+ })
2152
+
2153
+ ctx.dshGo.panel('ssh-config', {
2154
+ view(scope, caps) {
2155
+ const en = enableText(caps)
2156
+ const cfg = loadConfig(ctx, scope)
2157
+ const components = Array.isArray(caps?.components) ? caps.components : []
2158
+ const canForm = components.includes('form') && components.includes('textField')
2159
+ const children = [{
2160
+ type: 'text',
2161
+ text: en
2162
+ ? (cfg.ssh.host ? `Current: ${cfg.ssh.user ? `${cfg.ssh.user}@` : ''}${cfg.ssh.host}:${cfg.ssh.port}` : 'No SSH host configured yet.')
2163
+ : (cfg.ssh.host ? `当前:${cfg.ssh.user ? `${cfg.ssh.user}@` : ''}${cfg.ssh.host}:${cfg.ssh.port}` : '还没有配置 SSH 主机。'),
2164
+ }]
2165
+ if (canForm) {
2166
+ children.push({ type: 'form', submit: 'save-ssh', submitLabel: en ? 'Save' : '保存', children: [
2167
+ { type: 'textField', label: en ? 'Host' : '主机', bind: 'data.ssh.host', placeholder: '192.168.1.10' },
2168
+ { type: 'textField', label: en ? 'Port' : '端口', bind: 'data.ssh.port', placeholder: String(cfg.ssh.port) },
2169
+ { type: 'textField', label: en ? 'User' : '用户', bind: 'data.ssh.user', placeholder: 'root' },
2170
+ { type: 'textField', label: en ? 'Identity file' : '私钥路径', bind: 'data.ssh.identity', placeholder: '~/.ssh/id_ed25519' },
2171
+ { type: 'textField', label: en ? 'Remote home' : '远端 HOME', bind: 'data.ssh.remoteHome', placeholder: cfg.ssh.remoteHome },
2172
+ ] })
2173
+ } else {
2174
+ children.push({ type: 'callout', tone: 'info', text: en
2175
+ ? 'This app version has no panel input; configure it on the desktop settings page.'
2176
+ : '当前 App 版本不支持面板输入,请用电脑端设置页配置。' })
2177
+ }
2178
+ children.push({ type: 'callout', tone: 'info', text: en
2179
+ ? 'SSH uses a key or agent. Fields left empty keep their current value.'
2180
+ : 'SSH 用密钥或 agent;留空的字段保持原值。' })
2181
+ const view = { type: 'stack', title: en ? 'Configure SSH' : '配置 SSH', children }
2182
+ if (canForm) view.v = 2
2183
+ return view
2184
+ },
2185
+ data(scope, emit) {
2186
+ emit({ ssh: { host: '', port: '', user: '', identity: '', remoteHome: '' } })
2187
+ return () => {}
2188
+ },
2189
+ actions: {
2190
+ 'save-ssh'(scope, event) {
2191
+ const values = event?.value?.values && typeof event.value.values === 'object' ? event.value.values : {}
2192
+ const pick = (key) => (typeof values[key] === 'string' ? values[key].trim() : '')
2193
+ const cfg = loadConfig(ctx, scope)
2194
+ const port = Number(pick('data.ssh.port'))
2195
+ const next = {
2196
+ relay: cfg.relay,
2197
+ ssh: {
2198
+ host: pick('data.ssh.host') || cfg.ssh.host,
2199
+ port: Number.isInteger(port) && port > 0 && port < 65536 ? port : cfg.ssh.port,
2200
+ user: pick('data.ssh.user') || cfg.ssh.user,
2201
+ identity: pick('data.ssh.identity') || cfg.ssh.identity,
2202
+ remoteHome: pick('data.ssh.remoteHome') || cfg.ssh.remoteHome,
2203
+ },
2204
+ }
2205
+ try { writeConfig(ctx, scope, next) } catch { return { toast: '保存失败,检查工作区权限' } }
2206
+ return [{ toast: '已保存 SSH 配置' }, { open: 'panel:sync' }]
2207
+ },
2208
+ back() {
2209
+ return { open: 'panel:sync' }
2210
+ },
2211
+ },
2212
+ })
2213
+
2073
2214
  ctx.dshGo.strip('pending', (scope, emit, caps) => {
2074
2215
  const en = String(caps?.locale || '').toLowerCase().startsWith('en')
2075
2216
  const tick = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-go-plugin-sync",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "dsh": {