dsh-solution-ledger 0.2.2 → 0.2.4
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 +52 -1
- package/cordis.patch.yml +25 -0
- package/lib/backup.js +259 -0
- package/lib/client.js +278 -1
- package/lib/index.js +140 -9
- package/lib/update.js +257 -0
- package/package.json +4 -6
package/README.md
CHANGED
|
@@ -130,7 +130,48 @@ git clone https://github.com/Catwb/dsh-solution-ledger.git
|
|
|
130
130
|
- 状态操作:**确认**(草稿 → 已确认,只有确认过的才会参与自动推送)、退回草稿、弃用、归档、删除
|
|
131
131
|
- 顶部显示总数与各状态计数,底部显示存储文件的实际路径
|
|
132
132
|
|
|
133
|
-
Host
|
|
133
|
+
Host 半为此注册了六条路由:`GET /solution-ledger/list`、`POST /solution-ledger/update`、`POST /solution-ledger/delete`、`GET /solution-ledger/update-check`、`POST /solution-ledger/backup`、`GET /solution-ledger/backups`。
|
|
134
|
+
|
|
135
|
+
## 更新检查
|
|
136
|
+
|
|
137
|
+
面板打开时会查一次自己有没有新版本。查到就在顶部显示一条提示,点**去更新**跳到 **Plugins** 页里这个插件的详情页,用那里的 **Update** 完成安装。插件自己**不装**——`updateBundle` 会先卸载旧版再装新版,而承载这个请求的正是被卸载的那个插件,中途断线是必然的。跳转过去用 DSH 原生的确认框、进度和失败回滚,比自己实现一遍可靠。
|
|
138
|
+
|
|
139
|
+
### 为什么不用 DSH 自带的版本列表
|
|
140
|
+
|
|
141
|
+
`pluginManager.listVersions()` 底层跑 `pnpm view`,问的是 **pnpm 配置的 registry**。中国大陆的 `pnpm` 默认指向 `registry.npmmirror.com`,而镜像同步滞后:
|
|
142
|
+
|
|
143
|
+
| 源 | `dsh-solution-ledger` 的 latest |
|
|
144
|
+
|---|---|
|
|
145
|
+
| `registry.npmjs.org` | 0.2.3 |
|
|
146
|
+
| `registry.npmmirror.com` | 0.2.2 |
|
|
147
|
+
|
|
148
|
+
当时镜像上 `0.2.3` 的元数据和 tarball **都是 404**,加 `?t=` 时间戳、发 `no-cache` 都没用——不是 HTTP 缓存,是镜像服务端还没同步。所以刚发完版的这段时间里,走镜像的检查一律回答「已是最新」,这正是最需要看到新版本的时候。
|
|
149
|
+
|
|
150
|
+
于是这里:**官方源先查,镜像作对照**。两边都答上来且镜像落后时,提示里会直接写出 `npmjs v0.2.4 / npmmirror v0.2.3` 并提醒安装时把源切到 `registry.npmjs.org`,否则 Plugins 页会因为镜像拿不到这个版本而报错。
|
|
151
|
+
|
|
152
|
+
### 更新前的两道闸
|
|
153
|
+
|
|
154
|
+
点**去更新**不会立刻跳走,中间有两步,任何一步不过就不放行:
|
|
155
|
+
|
|
156
|
+
**第一道:源真的能下载吗。** `dist-tags` 里有版本号,不等于 tarball 拿得到——镜像上就出现过 tag 有、文件 404 的情况。所以对目标版本发一次带 `Range: bytes=0-0` 的 GET,官方源和镜像各问一遍,拿到真实状态码(`200` / `206` 算可用)。**所有源都取不到就拒绝跳转**,因为这时的更新会变成「卸载了旧版却没东西可装」,比不更新糟得多。面板上会直接显示每个源的实测状态,例如:
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
源状态 · registry.npmjs.org 206 / registry.npmmirror.com 404
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**第二道:旧版留了底吗。** 跳转前把当前正在跑的包目录整个复制到 `$DSH_HOME/solution-ledger-backups/<版本>-<时间戳>/`,排除 `node_modules` 和 `.git`。`updateBundle` 只升不降,发布的版本也可能本身就是坏的,没有这份副本就没有本地退路。
|
|
163
|
+
|
|
164
|
+
备份目录**本身就是一个完整可安装的包**,所以回退只有一条命令:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
dsh plugin --profile <profile> 名 add file:<备份目录>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
目录里还写了 `backup.json`(版本、时间、文件数、来源)和 `RESTORE.md`(回退步骤,link 安装的情况给出 `git checkout` 的做法)。备份失败时会弹确认框问是否仍然继续,默认不继续。
|
|
171
|
+
|
|
172
|
+
### 缓存
|
|
173
|
+
|
|
174
|
+
一次检查结果复用 `updateCheckTtlMs`(默认 5 分钟)。刻意设得很短:窗口一长,「检查更新」就会退化成它本来要解决的谎话。**重新检查**按钮带 `?force=1`,直接绕过缓存。
|
|
134
175
|
|
|
135
176
|
## 配置
|
|
136
177
|
|
|
@@ -144,6 +185,14 @@ Host 半为此注册了三条路由:`GET /solution-ledger/list`、`POST /solut
|
|
|
144
185
|
| `archiveAfterDays` | `90` | 超过这么多天未被命中的条目移出检索(不删除) |
|
|
145
186
|
| `draftArchiveAfterDays` | `30` | 草稿且**从未被命中**,超过这么多天自动归档(不删除) |
|
|
146
187
|
| `statePath` | `''` | 空则用 `$DSH_HOME/solution-ledger.json` |
|
|
188
|
+
| `updateCheck` | `true` | 面板顶部是否检查新版本 |
|
|
189
|
+
| `updateCheckTtlMs` | `300000` | 一次检查结果复用多久。别调大,长了就看不见刚发布的版本 |
|
|
190
|
+
| `updateCheckTimeoutMs` | `8000` | 单次 registry 查询的超时 |
|
|
191
|
+
| `updateCheckPackage` | `'dsh-solution-ledger'` | 检查哪个包;改名 fork 时才需要动 |
|
|
192
|
+
| `updateCheckRegistry` | `'https://registry.npmjs.org'` | 权威源,先查。发布在这里最先可见 |
|
|
193
|
+
| `updateCheckMirror` | `'https://registry.npmmirror.com'` | 对照用的镜像;落后会被标出来。设为空字符串则跳过对照 |
|
|
194
|
+
| `backupOnUpdate` | `true` | 跳转去更新前是否先备份当前版本 |
|
|
195
|
+
| `backupPath` | `''` | 空则用 `$DSH_HOME/solution-ledger-backups` |
|
|
147
196
|
|
|
148
197
|
## 限制
|
|
149
198
|
|
|
@@ -151,6 +200,8 @@ Host 半为此注册了三条路由:`GET /solution-ledger/list`、`POST /solut
|
|
|
151
200
|
- **界面不能新建条目。** 侧边栏面板可以查看、编辑、确认、弃用、归档和删除,但新增条目必须走 `solution_log`。
|
|
152
201
|
- **单进程。** 存储是本地文件,两个 DSH 进程同时写会互相覆盖。
|
|
153
202
|
- **`decision` 类不做自动推送。** 选技术路线不产生错误事件,这类条目只能靠 `solution_search` 主动查。
|
|
203
|
+
- **更新检查不装、只报。** 点**去更新**只是跳到 Plugins 页;装不装、装哪个版本由那里的确认框决定。镜像滞后时,安装那一步仍可能要求你把源切到官方源。
|
|
204
|
+
- **更新检查需要出网。** 查不到就是查不到,不会拿缓存冒充新结果——失败时明确显示失败原因。
|
|
154
205
|
|
|
155
206
|
## 许可证
|
|
156
207
|
|
package/cordis.patch.yml
CHANGED
|
@@ -17,3 +17,28 @@
|
|
|
17
17
|
draftArchiveAfterDays: 30
|
|
18
18
|
# Absolute path for the JSON store. Empty uses $DSH_HOME/solution-ledger.json.
|
|
19
19
|
statePath: ''
|
|
20
|
+
# Offer an update check in the panel. The check only reports; it never
|
|
21
|
+
# installs, because replacing this package would unload the plugin
|
|
22
|
+
# serving the request.
|
|
23
|
+
updateCheck: true
|
|
24
|
+
# How long a checked answer is reused. Keep this short: a long window
|
|
25
|
+
# reproduces the "already up to date" lie the check exists to avoid.
|
|
26
|
+
updateCheckTtlMs: 300000
|
|
27
|
+
# Per-request deadline for one registry lookup, in milliseconds.
|
|
28
|
+
updateCheckTimeoutMs: 8000
|
|
29
|
+
# Package to ask about. Change it only when forking under another name.
|
|
30
|
+
updateCheckPackage: 'dsh-solution-ledger'
|
|
31
|
+
# Authoritative source, asked first. A publish reaches npmjs before any
|
|
32
|
+
# mirror, so this is the only source that can see a fresh release.
|
|
33
|
+
updateCheckRegistry: 'https://registry.npmjs.org'
|
|
34
|
+
# Mirror to compare against. It is reported as lagging when it is
|
|
35
|
+
# behind, which is usually why an install says the version is missing,
|
|
36
|
+
# and why DSH's own version list shows nothing new. Empty disables it.
|
|
37
|
+
updateCheckMirror: 'https://registry.npmmirror.com'
|
|
38
|
+
# Save the running version before sending the user to the Plugins page.
|
|
39
|
+
# updateBundle refuses to go backwards, so this copy is the only local
|
|
40
|
+
# way back from a broken release.
|
|
41
|
+
backupOnUpdate: true
|
|
42
|
+
# Where rollback copies go. Empty uses $DSH_HOME/solution-ledger-backups.
|
|
43
|
+
# Each copy is a complete installable package.
|
|
44
|
+
backupPath: ''
|
package/lib/backup.js
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-flight checks and rollback copies for an update.
|
|
3
|
+
*
|
|
4
|
+
* Two things must be true before this plugin sends anyone to the Plugins page
|
|
5
|
+
* to install a newer version:
|
|
6
|
+
*
|
|
7
|
+
* 1. The target version is actually downloadable. A version that exists in
|
|
8
|
+
* `dist-tags` but whose tarball 404s would leave the user with a removal and
|
|
9
|
+
* no installation, which is the worst outcome of an update.
|
|
10
|
+
* 2. The running version can be brought back. A published release can be
|
|
11
|
+
* broken, and `updateBundle` refuses to go backwards, so the copy taken here
|
|
12
|
+
* is the only local way back.
|
|
13
|
+
*
|
|
14
|
+
* The backup is a complete, installable package directory: rollback is
|
|
15
|
+
* `dsh plugin add file:<backup>`.
|
|
16
|
+
*/
|
|
17
|
+
import {
|
|
18
|
+
copyFileSync,
|
|
19
|
+
existsSync,
|
|
20
|
+
mkdirSync,
|
|
21
|
+
readFileSync,
|
|
22
|
+
readdirSync,
|
|
23
|
+
statSync,
|
|
24
|
+
writeFileSync,
|
|
25
|
+
} from 'node:fs'
|
|
26
|
+
import { basename, dirname, join, resolve, sep } from 'node:path'
|
|
27
|
+
import { fileURLToPath } from 'node:url'
|
|
28
|
+
|
|
29
|
+
/** Directories never worth copying: rebuilt or re-fetched, and often huge. */
|
|
30
|
+
const EXCLUDED = new Set(['node_modules', '.git', '.pnpm-store'])
|
|
31
|
+
|
|
32
|
+
/** Metadata file written beside a backup copy. */
|
|
33
|
+
export const MANIFEST_NAME = 'backup.json'
|
|
34
|
+
|
|
35
|
+
/** Human-readable rollback steps written beside a backup copy. */
|
|
36
|
+
export const RESTORE_NAME = 'RESTORE.md'
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Resolve this package's own directory, the one holding `package.json`.
|
|
40
|
+
* @returns the absolute directory path.
|
|
41
|
+
*/
|
|
42
|
+
export function resolvePackageDir() {
|
|
43
|
+
return resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the backup root. Copies are global state like the ledger itself, so
|
|
48
|
+
* they belong beside it rather than inside a project checkout.
|
|
49
|
+
* @param config - the Loader row config.
|
|
50
|
+
* @returns absolute path of the directory holding every backup.
|
|
51
|
+
*/
|
|
52
|
+
export function resolveBackupsRoot(config) {
|
|
53
|
+
if (typeof config?.backupPath === 'string' && config.backupPath.length > 0) return config.backupPath
|
|
54
|
+
const home = process.env.DSH_HOME
|
|
55
|
+
if (typeof home === 'string' && home.length > 0) return join(home, 'solution-ledger-backups')
|
|
56
|
+
return join(process.cwd(), '.solution-ledger-backups')
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Copy one directory tree, skipping excluded directories.
|
|
61
|
+
* @param source - directory to read.
|
|
62
|
+
* @param target - directory to write into; created when missing.
|
|
63
|
+
* @returns the file count and byte total actually copied.
|
|
64
|
+
*/
|
|
65
|
+
function copyTree(source, target, stats = { files: 0, bytes: 0 }) {
|
|
66
|
+
for (const entry of readdirSync(source, { withFileTypes: true })) {
|
|
67
|
+
if (entry.isDirectory() && EXCLUDED.has(entry.name)) continue
|
|
68
|
+
const from = join(source, entry.name)
|
|
69
|
+
const to = join(target, entry.name)
|
|
70
|
+
if (entry.isDirectory()) {
|
|
71
|
+
mkdirSync(to, { recursive: true })
|
|
72
|
+
copyTree(from, to, stats)
|
|
73
|
+
continue
|
|
74
|
+
}
|
|
75
|
+
if (!entry.isFile()) continue
|
|
76
|
+
copyFileSync(from, to)
|
|
77
|
+
stats.files += 1
|
|
78
|
+
try {
|
|
79
|
+
stats.bytes += statSync(from).size
|
|
80
|
+
} catch {
|
|
81
|
+
// A size that cannot be read does not invalidate a completed copy.
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return stats
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Build one registry's tarball URL for an exact version.
|
|
89
|
+
* @param registry - registry base URL.
|
|
90
|
+
* @param packageName - package name.
|
|
91
|
+
* @param version - exact version.
|
|
92
|
+
* @returns the tarball URL.
|
|
93
|
+
*/
|
|
94
|
+
export function tarballUrl(registry, packageName, version) {
|
|
95
|
+
const base = String(registry).replace(/\/+$/, '')
|
|
96
|
+
return `${base}/${packageName}/-/${packageName}-${version}.tgz`
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Confirm a published version can actually be downloaded.
|
|
101
|
+
*
|
|
102
|
+
* A `dist-tags` entry proves only that the version was published, not that the
|
|
103
|
+
* file behind it resolves — and a mirror can carry the tag without the tarball.
|
|
104
|
+
* The check is a ranged GET rather than HEAD because some CDNs answer HEAD with
|
|
105
|
+
* 405 while serving the body normally.
|
|
106
|
+
* @param options - availability parameters.
|
|
107
|
+
* @param options.registries - registries to ask, in reporting order.
|
|
108
|
+
* @returns one entry per registry, each with `ok` and `status`.
|
|
109
|
+
*/
|
|
110
|
+
export async function checkAvailability(options) {
|
|
111
|
+
const { packageName, version, registries, timeoutMs = 8000, fetchImpl = globalThis.fetch } = options ?? {}
|
|
112
|
+
const results = []
|
|
113
|
+
if (typeof fetchImpl !== 'function' || typeof version !== 'string' || version === '') return results
|
|
114
|
+
|
|
115
|
+
for (const registry of registries) {
|
|
116
|
+
const url = tarballUrl(registry, packageName, version)
|
|
117
|
+
const controller = new AbortController()
|
|
118
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs)
|
|
119
|
+
try {
|
|
120
|
+
const response = await fetchImpl(url, {
|
|
121
|
+
signal: controller.signal,
|
|
122
|
+
method: 'GET',
|
|
123
|
+
// One byte is enough to distinguish "served" from "not found" without
|
|
124
|
+
// downloading a package just to look at it.
|
|
125
|
+
headers: { Range: 'bytes=0-0', 'Cache-Control': 'no-cache' },
|
|
126
|
+
})
|
|
127
|
+
// 206 for a satisfied range, 200 for a registry that ignores Range.
|
|
128
|
+
const ok = response.status === 200 || response.status === 206
|
|
129
|
+
results.push({ registry, url, status: response.status, ok, error: ok ? null : `http ${response.status}` })
|
|
130
|
+
} catch (error) {
|
|
131
|
+
const reason = error?.name === 'AbortError' ? 'timeout' : String(error?.message ?? error).slice(0, 120)
|
|
132
|
+
results.push({ registry, url, status: 0, ok: false, error: reason })
|
|
133
|
+
} finally {
|
|
134
|
+
clearTimeout(timer)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return results
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Write the rollback document for one backup.
|
|
142
|
+
* @param meta - the backup metadata.
|
|
143
|
+
* @returns markdown text.
|
|
144
|
+
*/
|
|
145
|
+
function restoreDocument(meta) {
|
|
146
|
+
return [
|
|
147
|
+
`# Rollback for ${meta.packageName} ${meta.version}`,
|
|
148
|
+
'',
|
|
149
|
+
`Taken ${new Date(meta.createdAt).toISOString()} from \`${meta.source}\`.`,
|
|
150
|
+
`Contains ${meta.files} file(s), ${meta.bytes} byte(s).`,
|
|
151
|
+
'',
|
|
152
|
+
'This directory is a complete package: installing it restores the version',
|
|
153
|
+
'that was running when the copy was taken.',
|
|
154
|
+
'',
|
|
155
|
+
'## Registry install or link install',
|
|
156
|
+
'',
|
|
157
|
+
'```bash',
|
|
158
|
+
`dsh plugin --profile <profile> add file:${meta.path}`,
|
|
159
|
+
'```',
|
|
160
|
+
'',
|
|
161
|
+
'Remove and re-add the bundle if the profile already lists it:',
|
|
162
|
+
'',
|
|
163
|
+
'```bash',
|
|
164
|
+
`dsh plugin --profile <profile> remove ${meta.packageName}`,
|
|
165
|
+
`dsh plugin --profile <profile> add file:${meta.path}`,
|
|
166
|
+
'```',
|
|
167
|
+
'',
|
|
168
|
+
'## Development link',
|
|
169
|
+
'',
|
|
170
|
+
'When the plugin was linked from a Git checkout, that checkout can be rolled',
|
|
171
|
+
'back instead, which keeps the link intact:',
|
|
172
|
+
'',
|
|
173
|
+
'```bash',
|
|
174
|
+
`git -C "${meta.source}" log --oneline -5 # find the commit to return to`,
|
|
175
|
+
`git -C "${meta.source}" checkout <commit>`,
|
|
176
|
+
'```',
|
|
177
|
+
'',
|
|
178
|
+
'## Note',
|
|
179
|
+
'',
|
|
180
|
+
'A rolled-back copy carries whatever version it was taken from, so it may be',
|
|
181
|
+
'older than the newest published release. Reinstall from the registry when a',
|
|
182
|
+
'fixed version is available.',
|
|
183
|
+
'',
|
|
184
|
+
].join('\n')
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Copy the running package into the backup root.
|
|
189
|
+
* @param options - backup parameters.
|
|
190
|
+
* @param options.backupsRoot - directory holding every backup.
|
|
191
|
+
* @param options.version - version being backed up, used in the folder name.
|
|
192
|
+
* @param options.packageName - package name recorded in the manifest.
|
|
193
|
+
* @param options.packageDir - package directory; defaults to this package.
|
|
194
|
+
* @returns the written metadata.
|
|
195
|
+
*/
|
|
196
|
+
export function createBackup(options) {
|
|
197
|
+
const {
|
|
198
|
+
backupsRoot,
|
|
199
|
+
packageName,
|
|
200
|
+
version = '',
|
|
201
|
+
packageDir = resolvePackageDir(),
|
|
202
|
+
source,
|
|
203
|
+
} = options ?? {}
|
|
204
|
+
|
|
205
|
+
const sourceDir = resolve(packageDir)
|
|
206
|
+
const root = resolve(backupsRoot)
|
|
207
|
+
|
|
208
|
+
// Guard against a backup root inside the tree being copied: that would make
|
|
209
|
+
// the copy recurse into its own output.
|
|
210
|
+
if (root === sourceDir || root.startsWith(`${sourceDir}${sep}`)) {
|
|
211
|
+
throw new Error(`backup root ${root} is inside the package directory ${sourceDir}`)
|
|
212
|
+
}
|
|
213
|
+
if (!existsSync(join(sourceDir, 'package.json'))) {
|
|
214
|
+
throw new Error(`no package.json in ${sourceDir}`)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, '-')
|
|
218
|
+
const name = version === '' ? stamp : `${version}-${stamp}`
|
|
219
|
+
const target = join(root, name)
|
|
220
|
+
mkdirSync(target, { recursive: true })
|
|
221
|
+
|
|
222
|
+
const stats = copyTree(sourceDir, target)
|
|
223
|
+
const meta = {
|
|
224
|
+
schema: 1,
|
|
225
|
+
packageName,
|
|
226
|
+
version,
|
|
227
|
+
createdAt: Date.now(),
|
|
228
|
+
path: target,
|
|
229
|
+
source: source ?? sourceDir,
|
|
230
|
+
files: stats.files,
|
|
231
|
+
bytes: stats.bytes,
|
|
232
|
+
}
|
|
233
|
+
writeFileSync(join(target, MANIFEST_NAME), `${JSON.stringify(meta, null, 2)}\n`, 'utf8')
|
|
234
|
+
writeFileSync(join(target, RESTORE_NAME), restoreDocument(meta), 'utf8')
|
|
235
|
+
return meta
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* List the backups under one root, newest first.
|
|
240
|
+
* @param backupsRoot - directory holding every backup.
|
|
241
|
+
* @returns the readable manifests; unreadable entries are skipped.
|
|
242
|
+
*/
|
|
243
|
+
export function listBackups(backupsRoot) {
|
|
244
|
+
const root = resolve(backupsRoot)
|
|
245
|
+
if (!existsSync(root)) return []
|
|
246
|
+
const found = []
|
|
247
|
+
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
248
|
+
if (!entry.isDirectory()) continue
|
|
249
|
+
const manifestPath = join(root, entry.name, MANIFEST_NAME)
|
|
250
|
+
if (!existsSync(manifestPath)) continue
|
|
251
|
+
try {
|
|
252
|
+
const meta = JSON.parse(readFileSync(manifestPath, 'utf8'))
|
|
253
|
+
if (meta !== null && typeof meta === 'object') found.push({ ...meta, name: basename(entry.name) })
|
|
254
|
+
} catch {
|
|
255
|
+
// A half-written manifest simply does not appear in the list.
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return found.sort((left, right) => (right.createdAt ?? 0) - (left.createdAt ?? 0))
|
|
259
|
+
}
|
package/lib/client.js
CHANGED
|
@@ -18,6 +18,10 @@ window.__ModuleLoader__.load({
|
|
|
18
18
|
const LIST_URL = '/solution-ledger/list'
|
|
19
19
|
const UPDATE_URL = '/solution-ledger/update'
|
|
20
20
|
const DELETE_URL = '/solution-ledger/delete'
|
|
21
|
+
const CHECK_URL = '/solution-ledger/update-check'
|
|
22
|
+
const BACKUP_URL = '/solution-ledger/backup'
|
|
23
|
+
/** Own package name: the Plugins page is asked to open exactly this bundle. */
|
|
24
|
+
const PACKAGE_NAME = 'dsh-solution-ledger'
|
|
21
25
|
|
|
22
26
|
const KINDS = ['troubleshoot', 'decision']
|
|
23
27
|
const DOMAINS = ['environment', 'tooling', 'code', 'config', 'process', 'other']
|
|
@@ -70,6 +74,29 @@ window.__ModuleLoader__.load({
|
|
|
70
74
|
},
|
|
71
75
|
hits: '命中',
|
|
72
76
|
store: '存储位置',
|
|
77
|
+
updateChecking: '检查更新…',
|
|
78
|
+
updateAvailable: '有新版本',
|
|
79
|
+
updateCurrent: '当前',
|
|
80
|
+
updateLatest: '已是最新',
|
|
81
|
+
updateFailed: '更新检查失败',
|
|
82
|
+
updateNow: '去更新',
|
|
83
|
+
updateLater: '稍后',
|
|
84
|
+
updateRecheck: '重新检查',
|
|
85
|
+
updateCheckedAt: '检查于',
|
|
86
|
+
updateMirrorLag: '镜像未同步',
|
|
87
|
+
updateMirrorLagHint: '官方源已发布,npmmirror 仍停在旧版。安装时请把源切到 registry.npmjs.org,否则会装不到。',
|
|
88
|
+
updateDegraded: '官方源不可达,以下结果来自镜像,可能滞后',
|
|
89
|
+
updatePublishing: '官方源正在发布该版本,稍后再查',
|
|
90
|
+
updateHint: '在 Plugins 页对这个插件点 Update 即可,确认框里会显示目标版本。',
|
|
91
|
+
updateOpenFailed: '打不开 Plugins 页,请从侧边栏手动打开。',
|
|
92
|
+
updateSources: '源状态',
|
|
93
|
+
updateUnavailable: '目标版本在所有源上都取不到,先确认发布是否完成',
|
|
94
|
+
updateReadyForPlugins: '已备份,正在打开 Plugins 页',
|
|
95
|
+
backingUp: '正在备份…',
|
|
96
|
+
backupDone: '已备份旧版',
|
|
97
|
+
backupFailed: '备份失败',
|
|
98
|
+
backupFailedAsk: '仍要前往 Plugins 页更新吗?没有备份就无法从本地回退。',
|
|
99
|
+
restoreHint: '回退命令',
|
|
73
100
|
}
|
|
74
101
|
|
|
75
102
|
const en = {
|
|
@@ -119,6 +146,29 @@ window.__ModuleLoader__.load({
|
|
|
119
146
|
},
|
|
120
147
|
hits: 'Hits',
|
|
121
148
|
store: 'Store',
|
|
149
|
+
updateChecking: 'Checking for updates…',
|
|
150
|
+
updateAvailable: 'New version',
|
|
151
|
+
updateCurrent: 'current',
|
|
152
|
+
updateLatest: 'Up to date',
|
|
153
|
+
updateFailed: 'Update check failed',
|
|
154
|
+
updateNow: 'Update',
|
|
155
|
+
updateLater: 'Later',
|
|
156
|
+
updateRecheck: 'Check again',
|
|
157
|
+
updateCheckedAt: 'checked',
|
|
158
|
+
updateMirrorLag: 'mirror not synced',
|
|
159
|
+
updateMirrorLagHint: 'The official registry has this release but npmmirror still serves the old one. Switch the install source to registry.npmjs.org or the install will not find it.',
|
|
160
|
+
updateDegraded: 'Official registry unreachable; this answer came from the mirror and may lag',
|
|
161
|
+
updatePublishing: 'The registry is still finalizing this release, try again later',
|
|
162
|
+
updateHint: 'Open Plugins and press Update on this plugin; the confirmation shows the target version.',
|
|
163
|
+
updateOpenFailed: 'Could not open the Plugins page; open it from the sidebar.',
|
|
164
|
+
updateSources: 'Sources',
|
|
165
|
+
updateUnavailable: 'No source serves the target version yet; confirm the publish finished',
|
|
166
|
+
updateReadyForPlugins: 'Backed up; opening the Plugins page',
|
|
167
|
+
backingUp: 'Backing up…',
|
|
168
|
+
backupDone: 'Previous version saved',
|
|
169
|
+
backupFailed: 'Backup failed',
|
|
170
|
+
backupFailedAsk: 'Open the Plugins page anyway? Without a backup there is no local way back.',
|
|
171
|
+
restoreHint: 'restore with',
|
|
122
172
|
}
|
|
123
173
|
|
|
124
174
|
const CSS = [
|
|
@@ -132,6 +182,13 @@ window.__ModuleLoader__.load({
|
|
|
132
182
|
'.dsl-input:focus{outline:none;border-color:var(--dsw-alias-brand-primary)}',
|
|
133
183
|
'.dsl-select{box-sizing:border-box;height:32px;padding:0 8px;border-radius:var(--dsw-radius-md);border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font-family:inherit;font-size:13px;cursor:pointer}',
|
|
134
184
|
'.dsl-stats{display:flex;align-items:center;gap:10px;flex-wrap:wrap;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px}',
|
|
185
|
+
// Update strip. Deliberately quiet when everything is current: it must not
|
|
186
|
+
// compete with the ledger it sits above.
|
|
187
|
+
'.dsl-update{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:8px 12px;border-radius:var(--dsw-radius-md);border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary)}',
|
|
188
|
+
'.dsl-updateHot{border-color:var(--dsw-alias-brand-primary)}',
|
|
189
|
+
'.dsl-updateStrong{color:var(--dsw-alias-label-primary);font-weight:600;font-size:13px}',
|
|
190
|
+
'.dsl-updateHint{flex-basis:100%;font-size:12px;line-height:17px;color:var(--dsw-alias-label-secondary)}',
|
|
191
|
+
'.dsl-updateSpacer{flex:1}',
|
|
135
192
|
'.dsl-dot{width:4px;height:4px;border-radius:50%;background:var(--dsw-alias-label-secondary);opacity:.5}',
|
|
136
193
|
'.dsl-list{display:flex;flex-direction:column;gap:8px}',
|
|
137
194
|
'.dsl-item{background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-md);box-sizing:border-box;overflow:hidden}',
|
|
@@ -267,6 +324,15 @@ window.__ModuleLoader__.load({
|
|
|
267
324
|
const [statusFilter, setStatusFilter] = React.useState('all')
|
|
268
325
|
const [openId, setOpenId] = React.useState(null)
|
|
269
326
|
const [notice, setNotice] = React.useState(null)
|
|
327
|
+
// `idle` until the first answer lands; `ready` carries the Host report.
|
|
328
|
+
// `backup` holds the last confirmed rollback copy for this version.
|
|
329
|
+
const [updateState, setUpdateState] = React.useState({
|
|
330
|
+
phase: 'idle',
|
|
331
|
+
report: null,
|
|
332
|
+
error: null,
|
|
333
|
+
backup: null,
|
|
334
|
+
})
|
|
335
|
+
const [updateDismissed, setUpdateDismissed] = React.useState(false)
|
|
270
336
|
|
|
271
337
|
const load = React.useCallback(async () => {
|
|
272
338
|
try {
|
|
@@ -289,6 +355,36 @@ window.__ModuleLoader__.load({
|
|
|
289
355
|
void load()
|
|
290
356
|
}, [load])
|
|
291
357
|
|
|
358
|
+
/**
|
|
359
|
+
* Ask the Host whether a newer version exists.
|
|
360
|
+
*
|
|
361
|
+
* `force` bypasses the Host's short cache, which is what the page offers
|
|
362
|
+
* right after a publish: the whole point is to see a version that a
|
|
363
|
+
* cached answer would still deny.
|
|
364
|
+
* @param force - skip the Host-side cached answer.
|
|
365
|
+
*/
|
|
366
|
+
const checkUpdate = React.useCallback(async (force) => {
|
|
367
|
+
setUpdateState((current) => ({ ...current, phase: 'checking', error: null }))
|
|
368
|
+
try {
|
|
369
|
+
const response = await fetch(force === true ? `${CHECK_URL}?force=1` : CHECK_URL, {
|
|
370
|
+
headers: { Accept: 'application/json' },
|
|
371
|
+
})
|
|
372
|
+
const answer = await readAnswer(response)
|
|
373
|
+
if (answer.disabled === true) {
|
|
374
|
+
setUpdateState((current) => ({ ...current, phase: 'disabled', report: null, error: null }))
|
|
375
|
+
return
|
|
376
|
+
}
|
|
377
|
+
if (answer.ok !== true) throw new Error(answer.error ?? 'unreachable')
|
|
378
|
+
setUpdateState((current) => ({ ...current, phase: 'ready', report: answer, error: null }))
|
|
379
|
+
} catch (error) {
|
|
380
|
+
setUpdateState((current) => ({ ...current, phase: 'failed', report: null, error: String(error) }))
|
|
381
|
+
}
|
|
382
|
+
}, [])
|
|
383
|
+
|
|
384
|
+
React.useEffect(() => {
|
|
385
|
+
void checkUpdate(false)
|
|
386
|
+
}, [checkUpdate])
|
|
387
|
+
|
|
292
388
|
/**
|
|
293
389
|
* Send one patch and fold the answer back into the list.
|
|
294
390
|
* @param id - target entry id.
|
|
@@ -510,6 +606,154 @@ window.__ModuleLoader__.load({
|
|
|
510
606
|
)
|
|
511
607
|
})
|
|
512
608
|
|
|
609
|
+
/** Local clock time for a check, so a stale answer is recognizable. */
|
|
610
|
+
const clock = (ms) => {
|
|
611
|
+
try {
|
|
612
|
+
return new Date(ms).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
|
|
613
|
+
} catch {
|
|
614
|
+
return ''
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/** Short host name for a registry URL, so a source line stays readable. */
|
|
619
|
+
const hostOf = (url) => {
|
|
620
|
+
try {
|
|
621
|
+
return new URL(url).host
|
|
622
|
+
} catch {
|
|
623
|
+
return String(url)
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Reaching the Plugins page is the only way this plugin installs
|
|
629
|
+
* anything, so the two safety steps happen here first:
|
|
630
|
+
*
|
|
631
|
+
* 1. Every registry is asked for the target tarball. A version in
|
|
632
|
+
* `dist-tags` whose file 404s everywhere would turn an update into a
|
|
633
|
+
* removal with nothing to install, so it is refused up front.
|
|
634
|
+
* 2. The running copy is saved before leaving. `updateBundle` will not
|
|
635
|
+
* move backwards, so without this copy there is no local way back.
|
|
636
|
+
*/
|
|
637
|
+
const goUpdate = async (report, installable, hasBackup) => {
|
|
638
|
+
if (installable !== true) {
|
|
639
|
+
setNotice({ text: t('updateUnavailable'), failed: true })
|
|
640
|
+
return
|
|
641
|
+
}
|
|
642
|
+
if (hasBackup !== true) {
|
|
643
|
+
setUpdateState((current) => ({ ...current, phase: 'backing-up', error: null }))
|
|
644
|
+
try {
|
|
645
|
+
const response = await fetch(BACKUP_URL, {
|
|
646
|
+
method: 'POST',
|
|
647
|
+
headers: { 'Content-Type': 'application/json' },
|
|
648
|
+
body: '{}',
|
|
649
|
+
})
|
|
650
|
+
const answer = await readAnswer(response)
|
|
651
|
+
if (answer.ok !== true) throw new Error(answer.error ?? 'backup failed')
|
|
652
|
+
setUpdateState((current) => ({ ...current, phase: 'ready', backup: answer.backup }))
|
|
653
|
+
} catch (error) {
|
|
654
|
+
setUpdateState((current) => ({ ...current, phase: 'ready' }))
|
|
655
|
+
const proceed =
|
|
656
|
+
typeof window === 'undefined' ||
|
|
657
|
+
window.confirm(`${t('backupFailed')}: ${String(error)}\n\n${t('backupFailedAsk')}`)
|
|
658
|
+
if (!proceed) return
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
if (props.openPlugins?.() !== true) setNotice({ text: t('updateOpenFailed'), failed: true })
|
|
662
|
+
else setNotice({ text: t('updateReadyForPlugins'), failed: false })
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* The update strip. Silent unless there is something to say: a check that
|
|
667
|
+
* is running, failed, or found a newer version. A successful "up to date"
|
|
668
|
+
* collapses to one quiet line because it still proves the check ran.
|
|
669
|
+
*/
|
|
670
|
+
const updateStrip = (() => {
|
|
671
|
+
if (updateState.phase === 'idle' || updateState.phase === 'disabled') return null
|
|
672
|
+
if (updateState.phase === 'checking') {
|
|
673
|
+
return h('div', { className: 'dsl-update' }, h('span', null, t('updateChecking')))
|
|
674
|
+
}
|
|
675
|
+
if (updateState.phase === 'failed') {
|
|
676
|
+
return h(
|
|
677
|
+
'div',
|
|
678
|
+
{ className: 'dsl-update' },
|
|
679
|
+
h('span', null, `${t('updateFailed')}: ${updateState.error}`),
|
|
680
|
+
h('span', { className: 'dsl-updateSpacer' }),
|
|
681
|
+
h('button', { type: 'button', className: 'dsl-btn', onClick: () => void checkUpdate(true) }, t('updateRecheck')),
|
|
682
|
+
)
|
|
683
|
+
}
|
|
684
|
+
const report = updateState.report
|
|
685
|
+
if (report === null) return null
|
|
686
|
+
|
|
687
|
+
if (report.hasUpdate !== true) {
|
|
688
|
+
return h(
|
|
689
|
+
'div',
|
|
690
|
+
{ className: 'dsl-update' },
|
|
691
|
+
h(
|
|
692
|
+
'span',
|
|
693
|
+
null,
|
|
694
|
+
report.publishing === true
|
|
695
|
+
? t('updatePublishing')
|
|
696
|
+
: `${t('updateLatest')} · v${report.current || report.latest}`,
|
|
697
|
+
),
|
|
698
|
+
h('span', { className: 'dsl-updateSpacer' }),
|
|
699
|
+
h('span', null, `${t('updateCheckedAt')} ${clock(report.checkedAt)}`),
|
|
700
|
+
h('button', { type: 'button', className: 'dsl-btn', onClick: () => void checkUpdate(true) }, t('updateRecheck')),
|
|
701
|
+
)
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
if (updateDismissed) return null
|
|
705
|
+
const mirror = report.mirror
|
|
706
|
+
const availability = Array.isArray(report.availability) ? report.availability : []
|
|
707
|
+
const installable = report.installable === true
|
|
708
|
+
const backup = updateState.backup
|
|
709
|
+
const busy = updateState.phase === 'backing-up'
|
|
710
|
+
|
|
711
|
+
// Every line here answers "why am I allowed / not allowed to install".
|
|
712
|
+
const detail = []
|
|
713
|
+
if (availability.length > 0) {
|
|
714
|
+
detail.push(
|
|
715
|
+
`${t('updateSources')} · ${availability
|
|
716
|
+
.map((entry) => `${hostOf(entry.registry)} ${entry.ok === true ? '200' : entry.status || entry.error}`)
|
|
717
|
+
.join(' / ')}`,
|
|
718
|
+
)
|
|
719
|
+
}
|
|
720
|
+
if (mirror !== null && mirror.lagging === true) {
|
|
721
|
+
detail.push(`${t('updateMirrorLag')} · ${t('updateMirrorLagHint')}`)
|
|
722
|
+
} else if (report.degraded === true) {
|
|
723
|
+
detail.push(t('updateDegraded'))
|
|
724
|
+
}
|
|
725
|
+
if (installable !== true) detail.push(t('updateUnavailable'))
|
|
726
|
+
if (backup !== null) {
|
|
727
|
+
detail.push(`${t('backupDone')} · ${backup.path} · ${t('restoreHint')} ${backup.restoreCommand}`)
|
|
728
|
+
} else if (installable === true) {
|
|
729
|
+
detail.push(t('updateHint'))
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
return h(
|
|
733
|
+
'div',
|
|
734
|
+
{ className: 'dsl-update dsl-updateHot' },
|
|
735
|
+
h('span', { className: 'dsl-updateStrong' }, `${t('updateAvailable')} v${report.latest}`),
|
|
736
|
+
h('span', null, `· ${t('updateCurrent')} v${report.current}`),
|
|
737
|
+
h('span', { className: 'dsl-updateSpacer' }),
|
|
738
|
+
h(
|
|
739
|
+
'button',
|
|
740
|
+
{
|
|
741
|
+
type: 'button',
|
|
742
|
+
className: 'dsl-btn dsl-btnPrimary',
|
|
743
|
+
disabled: busy,
|
|
744
|
+
onClick: () => void goUpdate(report, installable, backup !== null),
|
|
745
|
+
},
|
|
746
|
+
busy ? t('backingUp') : t('updateNow'),
|
|
747
|
+
),
|
|
748
|
+
h('button', { type: 'button', className: 'dsl-btn', onClick: () => setUpdateDismissed(true) }, t('updateLater')),
|
|
749
|
+
h(
|
|
750
|
+
'div',
|
|
751
|
+
{ className: 'dsl-updateHint' },
|
|
752
|
+
detail.map((line, index) => h('div', { key: `d${index}` }, line)),
|
|
753
|
+
),
|
|
754
|
+
)
|
|
755
|
+
})()
|
|
756
|
+
|
|
513
757
|
let list = rows
|
|
514
758
|
if (snapshot.phase === 'loading') list = h('div', { className: 'dsl-empty' }, t('loading'))
|
|
515
759
|
else if (snapshot.phase === 'failed') list = h('div', { className: 'dsl-empty' }, `${t('loadFailed')}: ${snapshot.error}`)
|
|
@@ -520,6 +764,7 @@ window.__ModuleLoader__.load({
|
|
|
520
764
|
'div',
|
|
521
765
|
{ className: 'dsl-page' },
|
|
522
766
|
h('p', { className: 'dsl-intro' }, t('intro')),
|
|
767
|
+
updateStrip,
|
|
523
768
|
h(
|
|
524
769
|
'div',
|
|
525
770
|
{ className: 'dsl-bar' },
|
|
@@ -584,7 +829,39 @@ window.__ModuleLoader__.load({
|
|
|
584
829
|
// `main` carries no translator, so the bound `t` is closed over once and
|
|
585
830
|
// the wrapper identity stays stable across renders.
|
|
586
831
|
function MainPanel(props) {
|
|
587
|
-
return h(LedgerPage, { ...props, t })
|
|
832
|
+
return h(LedgerPage, { ...props, t, openPlugins })
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Open this bundle's page on the official Plugins panel.
|
|
837
|
+
*
|
|
838
|
+
* `ui-plugin-manager` publishes `pluginNavigation` through Cordis
|
|
839
|
+
* reflect, and that opens the package's own detail page — the one place
|
|
840
|
+
* with a Versions section, an Update confirmation, progress and a
|
|
841
|
+
* rollback. Reimplementing the install here would mean replacing a
|
|
842
|
+
* package this very plugin runs from, so the button only navigates.
|
|
843
|
+
* @returns true when a navigation was issued.
|
|
844
|
+
*/
|
|
845
|
+
function openPlugins() {
|
|
846
|
+
try {
|
|
847
|
+
const navigation = ctx.reflect?.get?.('pluginNavigation')
|
|
848
|
+
if (navigation !== undefined && typeof navigation.openBundle === 'function') {
|
|
849
|
+
navigation.openBundle(PACKAGE_NAME)
|
|
850
|
+
return true
|
|
851
|
+
}
|
|
852
|
+
} catch (error) {
|
|
853
|
+
console.log('solution-ledger: pluginNavigation unavailable:', String(error))
|
|
854
|
+
}
|
|
855
|
+
try {
|
|
856
|
+
const layout = (typeof ctx.get === 'function' ? ctx.get('layout') : undefined) ?? ctx.layout
|
|
857
|
+
if (layout !== undefined && typeof layout.selectPanel === 'function') {
|
|
858
|
+
layout.selectPanel('plugins')
|
|
859
|
+
return true
|
|
860
|
+
}
|
|
861
|
+
} catch (error) {
|
|
862
|
+
console.log('solution-ledger: cannot open the Plugins panel:', String(error))
|
|
863
|
+
}
|
|
864
|
+
return false
|
|
588
865
|
}
|
|
589
866
|
|
|
590
867
|
const styleTag = document.createElement('style')
|
package/lib/index.js
CHANGED
|
@@ -14,6 +14,20 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { Ledger, resolveStatePath } from './store.js'
|
|
16
16
|
import { searchEntries } from './search.js'
|
|
17
|
+
import {
|
|
18
|
+
DEFAULT_MIRROR,
|
|
19
|
+
DEFAULT_REGISTRY,
|
|
20
|
+
PACKAGE_NAME,
|
|
21
|
+
checkForUpdate,
|
|
22
|
+
readOwnVersion,
|
|
23
|
+
} from './update.js'
|
|
24
|
+
import {
|
|
25
|
+
checkAvailability,
|
|
26
|
+
createBackup,
|
|
27
|
+
listBackups,
|
|
28
|
+
resolveBackupsRoot,
|
|
29
|
+
resolvePackageDir,
|
|
30
|
+
} from './backup.js'
|
|
17
31
|
|
|
18
32
|
export const name = 'solution-ledger'
|
|
19
33
|
|
|
@@ -36,6 +50,14 @@ const DEFAULTS = {
|
|
|
36
50
|
archiveAfterDays: 90,
|
|
37
51
|
draftArchiveAfterDays: 30,
|
|
38
52
|
statePath: '',
|
|
53
|
+
updateCheck: true,
|
|
54
|
+
updateCheckTtlMs: 300_000,
|
|
55
|
+
updateCheckTimeoutMs: 8000,
|
|
56
|
+
updateCheckPackage: PACKAGE_NAME,
|
|
57
|
+
updateCheckRegistry: DEFAULT_REGISTRY,
|
|
58
|
+
updateCheckMirror: DEFAULT_MIRROR,
|
|
59
|
+
backupOnUpdate: true,
|
|
60
|
+
backupPath: '',
|
|
39
61
|
}
|
|
40
62
|
|
|
41
63
|
/**
|
|
@@ -59,6 +81,24 @@ function normalizeConfig(raw) {
|
|
|
59
81
|
archiveAfterDays: int(source.archiveAfterDays, DEFAULTS.archiveAfterDays, 1, 3650),
|
|
60
82
|
draftArchiveAfterDays: int(source.draftArchiveAfterDays, DEFAULTS.draftArchiveAfterDays, 1, 3650),
|
|
61
83
|
statePath: typeof source.statePath === 'string' ? source.statePath : DEFAULTS.statePath,
|
|
84
|
+
updateCheck: bool(source.updateCheck, DEFAULTS.updateCheck),
|
|
85
|
+
// A short ceiling: a check that reuses an hour-old answer would reproduce
|
|
86
|
+
// the very "already up to date" lie this feature exists to avoid.
|
|
87
|
+
updateCheckTtlMs: int(source.updateCheckTtlMs, DEFAULTS.updateCheckTtlMs, 0, 3_600_000),
|
|
88
|
+
updateCheckTimeoutMs: int(source.updateCheckTimeoutMs, DEFAULTS.updateCheckTimeoutMs, 1000, 30_000),
|
|
89
|
+
updateCheckPackage:
|
|
90
|
+
typeof source.updateCheckPackage === 'string' && source.updateCheckPackage.trim() !== ''
|
|
91
|
+
? source.updateCheckPackage.trim()
|
|
92
|
+
: DEFAULTS.updateCheckPackage,
|
|
93
|
+
updateCheckRegistry:
|
|
94
|
+
typeof source.updateCheckRegistry === 'string' && source.updateCheckRegistry.trim() !== ''
|
|
95
|
+
? source.updateCheckRegistry.trim()
|
|
96
|
+
: DEFAULTS.updateCheckRegistry,
|
|
97
|
+
// An empty string disables the mirror comparison on purpose.
|
|
98
|
+
updateCheckMirror:
|
|
99
|
+
typeof source.updateCheckMirror === 'string' ? source.updateCheckMirror.trim() : DEFAULTS.updateCheckMirror,
|
|
100
|
+
backupOnUpdate: bool(source.backupOnUpdate, DEFAULTS.backupOnUpdate),
|
|
101
|
+
backupPath: typeof source.backupPath === 'string' ? source.backupPath : DEFAULTS.backupPath,
|
|
62
102
|
}
|
|
63
103
|
}
|
|
64
104
|
|
|
@@ -209,14 +249,13 @@ export async function apply(ctx, config) {
|
|
|
209
249
|
name: 'solution_log',
|
|
210
250
|
description:
|
|
211
251
|
'Record a problem whose root cause was not obvious, or a route you chose after genuinely rejecting a '
|
|
212
|
-
+ 'workable alternative, so a later session can skip the same search
|
|
213
|
-
+ '
|
|
214
|
-
+
|
|
215
|
-
+
|
|
216
|
-
+ '
|
|
217
|
-
+ '
|
|
218
|
-
+ '
|
|
219
|
-
+ 'New entries start as drafts and are not surfaced automatically until the user confirms them.',
|
|
252
|
+
+ 'workable alternative, so a later session can skip the same search. Do NOT record how something was '
|
|
253
|
+
+ 'implemented, what a file contains, or a decision where no alternative was seriously considered. If a '
|
|
254
|
+
+ "note would never appear in a failure message and would not change anyone's next decision, it is a log "
|
|
255
|
+
+ 'line, not a ledger entry. Before calling, all three must be true: (1) a future session is likely to '
|
|
256
|
+
+ 'hit the same situation; (2) the answer is not obvious from one glance at the code or docs; (3) '
|
|
257
|
+
+ 'skipping this entry would cost that session real time. New entries start as drafts and are not '
|
|
258
|
+
+ 'surfaced automatically until the user confirms them.',
|
|
220
259
|
parameters: {
|
|
221
260
|
kind: {
|
|
222
261
|
type: 'string',
|
|
@@ -233,7 +272,7 @@ export async function apply(ctx, config) {
|
|
|
233
272
|
title: {
|
|
234
273
|
type: 'string',
|
|
235
274
|
required: true,
|
|
236
|
-
description: 'One-line conclusion that reads as a finding. A statement like
|
|
275
|
+
description: 'One-line conclusion that reads as a finding. A statement like `we use X to do Y` is an implementation note, not a finding.',
|
|
237
276
|
},
|
|
238
277
|
problem: {
|
|
239
278
|
type: 'string',
|
|
@@ -672,6 +711,98 @@ export async function apply(ctx, config) {
|
|
|
672
711
|
})
|
|
673
712
|
reply(res, 200, { ok: true, removed })
|
|
674
713
|
})
|
|
714
|
+
|
|
715
|
+
// ---- Update check ----------------------------------------------------
|
|
716
|
+
// The mirror a mainland China `pnpm` defaults to can sit a whole release
|
|
717
|
+
// behind npmjs, which makes DSH's own `listVersions()` answer "up to date"
|
|
718
|
+
// right after a publish. This route asks the authoritative registry and
|
|
719
|
+
// reports the mirror separately instead of trusting whichever answered.
|
|
720
|
+
const ownVersion = readOwnVersion()
|
|
721
|
+
const ownDir = resolvePackageDir()
|
|
722
|
+
const backupsRoot = resolveBackupsRoot(resolved)
|
|
723
|
+
let updateCache = null
|
|
724
|
+
let updateInflight = null
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* One full check: is there a newer version, and can it be fetched at all?
|
|
728
|
+
*
|
|
729
|
+
* The availability probe runs only when a newer version exists, so an
|
|
730
|
+
* install that is already current costs one lookup per registry rather than
|
|
731
|
+
* a tarball request as well. `installable` is the gate the page uses: a
|
|
732
|
+
* version whose tarball 404s everywhere would turn an update into a removal
|
|
733
|
+
* with nothing to install.
|
|
734
|
+
* @returns the report plus `availability` and `installable`.
|
|
735
|
+
*/
|
|
736
|
+
const performCheck = async () => {
|
|
737
|
+
const report = await checkForUpdate({
|
|
738
|
+
currentVersion: ownVersion,
|
|
739
|
+
packageName: resolved.updateCheckPackage,
|
|
740
|
+
registry: resolved.updateCheckRegistry,
|
|
741
|
+
mirror: resolved.updateCheckMirror === '' ? null : resolved.updateCheckMirror,
|
|
742
|
+
timeoutMs: resolved.updateCheckTimeoutMs,
|
|
743
|
+
})
|
|
744
|
+
if (report.hasUpdate !== true || typeof report.latest !== 'string') return report
|
|
745
|
+
|
|
746
|
+
const registries = [resolved.updateCheckRegistry]
|
|
747
|
+
if (resolved.updateCheckMirror !== '') registries.push(resolved.updateCheckMirror)
|
|
748
|
+
const availability = await checkAvailability({
|
|
749
|
+
packageName: resolved.updateCheckPackage,
|
|
750
|
+
version: report.latest,
|
|
751
|
+
registries,
|
|
752
|
+
timeoutMs: resolved.updateCheckTimeoutMs,
|
|
753
|
+
})
|
|
754
|
+
return { ...report, availability, installable: availability.some((entry) => entry.ok) }
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
route('/solution-ledger/update-check', async (req, res) => {
|
|
758
|
+
if (req.method !== 'GET') return reply(res, 405, { ok: false, error: 'method not allowed' })
|
|
759
|
+
if (!resolved.updateCheck) return reply(res, 200, { ok: false, disabled: true })
|
|
760
|
+
|
|
761
|
+
const requested = new URL(req.url ?? '/', 'http://localhost')
|
|
762
|
+
const force = requested.searchParams.get('force') === '1'
|
|
763
|
+
const age = updateCache === null ? Infinity : Date.now() - updateCache.at
|
|
764
|
+
if (!force && age < resolved.updateCheckTtlMs) {
|
|
765
|
+
return reply(res, 200, { ...updateCache.value, cached: true, cacheAgeMs: age })
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
if (updateInflight === null) {
|
|
769
|
+
updateInflight = performCheck().finally(() => {
|
|
770
|
+
updateInflight = null
|
|
771
|
+
})
|
|
772
|
+
}
|
|
773
|
+
const report = await updateInflight
|
|
774
|
+
updateCache = { at: Date.now(), value: report }
|
|
775
|
+
reply(res, 200, { ...report, cached: false, cacheAgeMs: 0 })
|
|
776
|
+
})
|
|
777
|
+
|
|
778
|
+
/** Report one backup's rollback command, so the page can show it. */
|
|
779
|
+
const describeBackup = (meta) => ({
|
|
780
|
+
...meta,
|
|
781
|
+
restoreCommand: `dsh plugin --profile <profile> add file:${meta.path}`,
|
|
782
|
+
})
|
|
783
|
+
|
|
784
|
+
route('/solution-ledger/backup', async (req, res) => {
|
|
785
|
+
if (req.method !== 'POST') return reply(res, 405, { ok: false, error: 'method not allowed' })
|
|
786
|
+
try {
|
|
787
|
+
const meta = createBackup({
|
|
788
|
+
backupsRoot,
|
|
789
|
+
packageName: resolved.updateCheckPackage,
|
|
790
|
+
version: ownVersion,
|
|
791
|
+
packageDir: ownDir,
|
|
792
|
+
source: ownDir,
|
|
793
|
+
})
|
|
794
|
+
reply(res, 200, { ok: true, backup: describeBackup(meta) })
|
|
795
|
+
} catch (error) {
|
|
796
|
+
// A failed copy must surface as a failure: the page treats a backup it
|
|
797
|
+
// cannot confirm as a reason not to send the user off to install.
|
|
798
|
+
reply(res, 500, { ok: false, error: String(error?.message ?? error) })
|
|
799
|
+
}
|
|
800
|
+
})
|
|
801
|
+
|
|
802
|
+
route('/solution-ledger/backups', async (req, res) => {
|
|
803
|
+
if (req.method !== 'GET') return reply(res, 405, { ok: false, error: 'method not allowed' })
|
|
804
|
+
reply(res, 200, { ok: true, root: backupsRoot, backups: listBackups(backupsRoot).map(describeBackup) })
|
|
805
|
+
})
|
|
675
806
|
}
|
|
676
807
|
|
|
677
808
|
// Push, not pull: a failing tool names its own problem in the same step it
|
package/lib/update.js
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self update check for this package.
|
|
3
|
+
*
|
|
4
|
+
* The hard part is not the request: it is which registry answers. A mainland
|
|
5
|
+
* China package manager defaults to `registry.npmmirror.com`, and that mirror
|
|
6
|
+
* lags npmjs by an unpredictable amount — measured here, a version published
|
|
7
|
+
* to npmjs was still 404 on the mirror minutes later, both its metadata and
|
|
8
|
+
* its tarball. DSH's own `pluginManager.listVersions()` runs `pnpm view`, so it
|
|
9
|
+
* asks the same lagging mirror and reports "already up to date".
|
|
10
|
+
*
|
|
11
|
+
* So this module asks the official registry first, asks the mirror second, and
|
|
12
|
+
* reports the difference instead of hiding it. Nothing here installs anything:
|
|
13
|
+
* the page only tells the user what exists.
|
|
14
|
+
*/
|
|
15
|
+
import { readFileSync } from 'node:fs'
|
|
16
|
+
import { dirname, join } from 'node:path'
|
|
17
|
+
import { fileURLToPath } from 'node:url'
|
|
18
|
+
|
|
19
|
+
/** The package this module checks. */
|
|
20
|
+
export const PACKAGE_NAME = 'dsh-solution-ledger'
|
|
21
|
+
|
|
22
|
+
/** Authoritative source: a publish lands here first. */
|
|
23
|
+
export const DEFAULT_REGISTRY = 'https://registry.npmjs.org'
|
|
24
|
+
|
|
25
|
+
/** Common mainland China mirror; usually behind the authoritative source. */
|
|
26
|
+
export const DEFAULT_MIRROR = 'https://registry.npmmirror.com'
|
|
27
|
+
|
|
28
|
+
/** npm's placeholder version while a publish is still being finalized. */
|
|
29
|
+
const STAGING_PREFIX = '0.0.0'
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Read this package's own version from its manifest.
|
|
33
|
+
*
|
|
34
|
+
* `package.json` is not re-exported through the `exports` whitelist, so it is
|
|
35
|
+
* read from the filesystem beside `lib/` rather than imported.
|
|
36
|
+
* @returns the version string, or an empty string when unreadable.
|
|
37
|
+
*/
|
|
38
|
+
export function readOwnVersion() {
|
|
39
|
+
try {
|
|
40
|
+
const here = dirname(fileURLToPath(import.meta.url))
|
|
41
|
+
const manifest = JSON.parse(readFileSync(join(here, '..', 'package.json'), 'utf8'))
|
|
42
|
+
return typeof manifest.version === 'string' ? manifest.version : ''
|
|
43
|
+
} catch {
|
|
44
|
+
return ''
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Split a version into comparable parts.
|
|
50
|
+
* @param value - a version string, with or without a leading `v`.
|
|
51
|
+
* @returns the parts, or null when the string is not a version.
|
|
52
|
+
*/
|
|
53
|
+
export function parseVersion(value) {
|
|
54
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(String(value ?? '').trim())
|
|
55
|
+
if (match === null) return null
|
|
56
|
+
return {
|
|
57
|
+
major: Number(match[1]),
|
|
58
|
+
minor: Number(match[2]),
|
|
59
|
+
patch: Number(match[3]),
|
|
60
|
+
prerelease: match[4] ?? '',
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Compare two versions the way semver orders them.
|
|
66
|
+
* @param left - first version.
|
|
67
|
+
* @param right - second version.
|
|
68
|
+
* @returns -1, 0, or 1; two unparsable versions compare equal.
|
|
69
|
+
*/
|
|
70
|
+
export function compareVersions(left, right) {
|
|
71
|
+
const a = parseVersion(left)
|
|
72
|
+
const b = parseVersion(right)
|
|
73
|
+
if (a === null || b === null) return 0
|
|
74
|
+
for (const key of ['major', 'minor', 'patch']) {
|
|
75
|
+
if (a[key] !== b[key]) return a[key] < b[key] ? -1 : 1
|
|
76
|
+
}
|
|
77
|
+
// A release outranks any prerelease of the same number.
|
|
78
|
+
if (a.prerelease === b.prerelease) return 0
|
|
79
|
+
if (a.prerelease === '') return 1
|
|
80
|
+
if (b.prerelease === '') return -1
|
|
81
|
+
return a.prerelease < b.prerelease ? -1 : 1
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Turn a thrown fetch failure into a short, reportable reason.
|
|
86
|
+
* @param error - whatever the request threw.
|
|
87
|
+
* @returns a one-word reason plus detail.
|
|
88
|
+
*/
|
|
89
|
+
function describeError(error) {
|
|
90
|
+
if (error?.name === 'AbortError') return 'timeout'
|
|
91
|
+
const message = String(error?.message ?? error)
|
|
92
|
+
if (/ENOTFOUND|EAI_AGAIN|getaddrinfo/i.test(message)) return 'dns'
|
|
93
|
+
if (/ECONNREFUSED|ECONNRESET|socket/i.test(message)) return 'connection'
|
|
94
|
+
if (/certificate|self-signed/i.test(message)) return 'tls'
|
|
95
|
+
return message.slice(0, 120)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Read one registry's `latest` dist-tag.
|
|
100
|
+
*
|
|
101
|
+
* The dist-tags endpoint is a few hundred bytes; the full manifest is hundreds
|
|
102
|
+
* of kilobytes, so it is only a fallback for a registry that does not serve the
|
|
103
|
+
* small one. Both carry a cache-busting query: the mirror ignores it, but a CDN
|
|
104
|
+
* in front of the official registry does not.
|
|
105
|
+
* @param registry - registry base URL.
|
|
106
|
+
* @param packageName - package to ask about.
|
|
107
|
+
* @param timeoutMs - per-request deadline.
|
|
108
|
+
* @param fetchImpl - fetch implementation to use.
|
|
109
|
+
* @returns `{ latest, error }` — `latest` is null when the registry had no answer.
|
|
110
|
+
*/
|
|
111
|
+
async function fetchLatestTag(registry, packageName, timeoutMs, fetchImpl) {
|
|
112
|
+
const base = String(registry).replace(/\/+$/, '')
|
|
113
|
+
const attempts = [
|
|
114
|
+
`${base}/-/package/${packageName}/dist-tags`,
|
|
115
|
+
`${base}/${packageName}/latest`,
|
|
116
|
+
]
|
|
117
|
+
let lastError = null
|
|
118
|
+
for (const target of attempts) {
|
|
119
|
+
const controller = new AbortController()
|
|
120
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs)
|
|
121
|
+
try {
|
|
122
|
+
const response = await fetchImpl(`${target}?t=${Date.now()}`, {
|
|
123
|
+
signal: controller.signal,
|
|
124
|
+
headers: { Accept: 'application/json', 'Cache-Control': 'no-cache', Pragma: 'no-cache' },
|
|
125
|
+
})
|
|
126
|
+
if (!response.ok) {
|
|
127
|
+
lastError = `http ${response.status}`
|
|
128
|
+
continue
|
|
129
|
+
}
|
|
130
|
+
const body = await response.json()
|
|
131
|
+
const latest =
|
|
132
|
+
typeof body?.latest === 'string'
|
|
133
|
+
? body.latest
|
|
134
|
+
: // A full manifest answers with its own version instead of a tag map.
|
|
135
|
+
typeof body?.version === 'string'
|
|
136
|
+
? body.version
|
|
137
|
+
: ''
|
|
138
|
+
if (latest === '') {
|
|
139
|
+
lastError = 'no latest tag'
|
|
140
|
+
continue
|
|
141
|
+
}
|
|
142
|
+
return { latest, error: null }
|
|
143
|
+
} catch (error) {
|
|
144
|
+
lastError = describeError(error)
|
|
145
|
+
} finally {
|
|
146
|
+
clearTimeout(timer)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return { latest: null, error: lastError ?? 'unreachable' }
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Check whether a newer version has been published.
|
|
154
|
+
*
|
|
155
|
+
* Both sources are asked in parallel so the answer can say that the official
|
|
156
|
+
* registry already has a version the mirror has not synced — the exact state
|
|
157
|
+
* that makes a mirror-only check report "up to date" after a publish.
|
|
158
|
+
* @param options - check parameters.
|
|
159
|
+
* @param options.currentVersion - the version this install is running.
|
|
160
|
+
* @param options.packageName - package to check.
|
|
161
|
+
* @param options.registry - authoritative registry.
|
|
162
|
+
* @param options.mirror - mirror to compare against, or null to skip it.
|
|
163
|
+
* @param options.timeoutMs - per-request deadline.
|
|
164
|
+
* @param options.fetchImpl - fetch implementation; defaults to the global one.
|
|
165
|
+
* @returns one normalized report; never throws.
|
|
166
|
+
*/
|
|
167
|
+
export async function checkForUpdate(options) {
|
|
168
|
+
const {
|
|
169
|
+
currentVersion,
|
|
170
|
+
packageName = PACKAGE_NAME,
|
|
171
|
+
registry = DEFAULT_REGISTRY,
|
|
172
|
+
mirror = DEFAULT_MIRROR,
|
|
173
|
+
timeoutMs = 8000,
|
|
174
|
+
fetchImpl = globalThis.fetch,
|
|
175
|
+
} = options ?? {}
|
|
176
|
+
|
|
177
|
+
const checkedAt = Date.now()
|
|
178
|
+
const base = {
|
|
179
|
+
ok: true,
|
|
180
|
+
current: typeof currentVersion === 'string' ? currentVersion : '',
|
|
181
|
+
packageName,
|
|
182
|
+
registry,
|
|
183
|
+
checkedAt,
|
|
184
|
+
latest: null,
|
|
185
|
+
hasUpdate: false,
|
|
186
|
+
publishing: false,
|
|
187
|
+
degraded: false,
|
|
188
|
+
mirror: null,
|
|
189
|
+
error: null,
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (typeof fetchImpl !== 'function') {
|
|
193
|
+
return { ...base, ok: false, error: 'no fetch implementation' }
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const [primary, secondary] = await Promise.all([
|
|
197
|
+
fetchLatestTag(registry, packageName, timeoutMs, fetchImpl),
|
|
198
|
+
mirror === null || mirror === undefined || mirror === registry
|
|
199
|
+
? Promise.resolve(null)
|
|
200
|
+
: fetchLatestTag(mirror, packageName, timeoutMs, fetchImpl),
|
|
201
|
+
])
|
|
202
|
+
|
|
203
|
+
// Prefer the authoritative answer; fall back to the mirror but say so, since
|
|
204
|
+
// a mirror answer can be behind the published state.
|
|
205
|
+
let latest = primary.latest
|
|
206
|
+
let usedRegistry = registry
|
|
207
|
+
let degraded = false
|
|
208
|
+
if (latest === null && secondary?.latest != null) {
|
|
209
|
+
latest = secondary.latest
|
|
210
|
+
usedRegistry = String(mirror)
|
|
211
|
+
degraded = true
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const mirrorReport =
|
|
215
|
+
secondary === null
|
|
216
|
+
? null
|
|
217
|
+
: {
|
|
218
|
+
registry: String(mirror),
|
|
219
|
+
latest: secondary.latest,
|
|
220
|
+
error: secondary.error,
|
|
221
|
+
// Only meaningful when both answered and the mirror is behind.
|
|
222
|
+
lagging:
|
|
223
|
+
primary.latest !== null &&
|
|
224
|
+
secondary.latest !== null &&
|
|
225
|
+
compareVersions(secondary.latest, primary.latest) < 0,
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (latest === null) {
|
|
229
|
+
return {
|
|
230
|
+
...base,
|
|
231
|
+
ok: false,
|
|
232
|
+
registry: usedRegistry,
|
|
233
|
+
degraded,
|
|
234
|
+
mirror: mirrorReport,
|
|
235
|
+
error: primary.error ?? 'unreachable',
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// npm briefly publishes `0.0.0-<stage>` before promoting the real version;
|
|
240
|
+
// reporting that as an update would be noise.
|
|
241
|
+
const publishing = latest === STAGING_PREFIX || latest.startsWith(`${STAGING_PREFIX}-`)
|
|
242
|
+
const hasUpdate =
|
|
243
|
+
!publishing &&
|
|
244
|
+
base.current !== '' &&
|
|
245
|
+
parseVersion(base.current) !== null &&
|
|
246
|
+
compareVersions(latest, base.current) > 0
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
...base,
|
|
250
|
+
latest,
|
|
251
|
+
registry: usedRegistry,
|
|
252
|
+
degraded,
|
|
253
|
+
publishing,
|
|
254
|
+
hasUpdate,
|
|
255
|
+
mirror: mirrorReport,
|
|
256
|
+
}
|
|
257
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-solution-ledger",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,14 +18,12 @@
|
|
|
18
18
|
"./package.json": "./package.json"
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
21
|
-
"lib
|
|
22
|
-
"lib/store.js",
|
|
23
|
-
"lib/search.js",
|
|
24
|
-
"lib/client.js",
|
|
21
|
+
"lib/*.js",
|
|
25
22
|
"cordis.patch.yml",
|
|
26
23
|
"locale/*.json",
|
|
27
24
|
"icon.svg",
|
|
28
|
-
"README.md"
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
29
27
|
],
|
|
30
28
|
"publishConfig": {
|
|
31
29
|
"access": "public"
|