dsh-release-depot 1.1.2 → 1.1.3
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 +25 -0
- package/README.md +6 -0
- package/client.js +28 -14
- package/index.js +1 -1
- package/lib/github.js +1 -1
- package/lib/net.js +16 -2
- package/lib/registry.js +32 -12
- package/lib/semver.js +3 -1
- package/lib/service.js +44 -15
- package/lib/tools.js +19 -13
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.3
|
|
4
|
+
|
|
5
|
+
### 修复
|
|
6
|
+
|
|
7
|
+
- npm publish 返回 `202 Accepted` 时,面板和 AI 工具明确显示“已受理,registry 同步中”,不再直接称为“发布完成”。
|
|
8
|
+
- GitHub Release 的自动安装段只在 npm 目标确实成功时出现,避免链接到不存在的包版本。
|
|
9
|
+
- 删除整个 npm 包现在在 `version: '*'` 和“仅剩一个版本”两种情况下都强制要求 `confirmName`,防止误删整包。
|
|
10
|
+
- 修复 AI 工具 `add-owner` / `remove-owner` 的变量遮蔽错误(之前两个动作都会抛 ReferenceError)。
|
|
11
|
+
- npm 访问级别统一为 `public` / `restricted`,与 npm `access set status` 协议一致;面板、工具、协议不再出现 private/restricted 混用。
|
|
12
|
+
- 代理 URL 中的用户名/密码在诊断信息中打码,不再进入面板或 AI 工具输出。
|
|
13
|
+
- 工具结果改为结构化 `data` 对象,去掉重复 JSON 编码;超长文本附带截断标记。
|
|
14
|
+
- npm Token 列表改为跟随分页,Token 数量超过一页时仍能匹配到期日。
|
|
15
|
+
- 修复 GitHub 仓库列表缓存忽略 `limit` 的问题;dist-tag/access/owner 操作后 npm 包列表缓存会失效。
|
|
16
|
+
- 发布预检在“仓库不存在且未勾选自动创建”时返回失败,不再让向导误判为可发布。
|
|
17
|
+
- 发布更新日志支持 `## [1.2.3]`、`## v1.2.3`、`## 1.2.3 — date` 等标题格式。
|
|
18
|
+
- 无效 dist-tag 直接报错,不再静默替换为 latest;`v1.2.3` 这类不规范 package version 在打包阶段拒绝。
|
|
19
|
+
- 删除 GitHub Release 现在需要 `force: true`;同时删除 tag 时必须提供 tag 名称。
|
|
20
|
+
- 主题与目录选择器改为注入服务,避免一次性读取导致深色主题或目录选择器失效。
|
|
21
|
+
- `npm_registry info` 支持按 `version` 查询指定版本;`github_publish release` 增加 `generateNotes`。
|
|
22
|
+
- README 增加版本更新日志入口。
|
|
23
|
+
|
|
24
|
+
### 说明
|
|
25
|
+
|
|
26
|
+
- 补丁版本,发布协议与目标不变。
|
|
27
|
+
|
|
3
28
|
## 1.1.2
|
|
4
29
|
|
|
5
30
|
### 修复
|
package/README.md
CHANGED
|
@@ -220,6 +220,12 @@ dsh-release-depot/
|
|
|
220
220
|
|
|
221
221
|
---
|
|
222
222
|
|
|
223
|
+
## 更新日志
|
|
224
|
+
|
|
225
|
+
每个版本的变更见 [CHANGELOG.md](CHANGELOG.md)。
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
223
229
|
## English
|
|
224
230
|
|
|
225
231
|
**Release Depot** connects npm and GitHub inside DeepSeek Harness and gives both the panel and the agent one shared publishing service: publish to npm / GitHub Packages, push a directory and create a GitHub Release with the tarball attached, manage dist-tags, access, maintainers and versions, and review a local publish log.
|
package/client.js
CHANGED
|
@@ -520,7 +520,7 @@ window.__ModuleLoader__.load({
|
|
|
520
520
|
h('div', null,
|
|
521
521
|
h('strong', null, t('仅本机凭据', 'Local credentials only')),
|
|
522
522
|
h('span', null, t('令牌只保存在 DSH home。', 'Tokens stay in your DSH home.')))),
|
|
523
|
-
h('div', { className: 'sd-side-foot' }, h('span', null, `v${status?.version ?? '1.1.
|
|
523
|
+
h('div', { className: 'sd-side-foot' }, h('span', null, `v${status?.version ?? '1.1.3'}`), h('span', null, t('本地运行', 'local runtime')))),
|
|
524
524
|
h('main', { className: 'sd-main' },
|
|
525
525
|
h('header', { className: 'sd-top' },
|
|
526
526
|
h('div', { className: 'sd-crumb' },
|
|
@@ -531,9 +531,9 @@ window.__ModuleLoader__.load({
|
|
|
531
531
|
h('span', { className: 'sd-pill ' + (status?.npm?.connected || status?.github?.connected ? 'sd-pill-ok' : 'sd-pill-warn') },
|
|
532
532
|
h('span', { className: 'sd-dot' }),
|
|
533
533
|
status?.npm?.connected && status?.github?.connected
|
|
534
|
-
? t('
|
|
534
|
+
? t('双账号已连接', 'Both accounts connected')
|
|
535
535
|
: status?.npm?.connected || status?.github?.connected
|
|
536
|
-
? t('
|
|
536
|
+
? t('单账号已连接', 'One account connected')
|
|
537
537
|
: t('账号未连接', 'No account yet')))),
|
|
538
538
|
h('div', { className: 'sd-hazard', 'aria-hidden': 'true' }),
|
|
539
539
|
h('div', { className: 'sd-content' },
|
|
@@ -1284,7 +1284,7 @@ window.__ModuleLoader__.load({
|
|
|
1284
1284
|
onChange: (event) => setAccessForm({ ...accessForm, access: event.target.value }),
|
|
1285
1285
|
},
|
|
1286
1286
|
h('option', { value: 'public' }, 'public'),
|
|
1287
|
-
h('option', { value: '
|
|
1287
|
+
h('option', { value: 'restricted' }, t('private(仅 scoped 包)', 'private (scoped only)'))),
|
|
1288
1288
|
h(TextInput, { placeholder: 'OTP', 'aria-label': t('一次性验证码', 'one-time code'), value: accessForm.otp, maxLength: 6, className: 'sd-input-mini', onChange: (event) => setAccessForm({ ...accessForm, otp: event.target.value }) }),
|
|
1289
1289
|
h(Btn, { size: 'sm', variant: 'primary', busy: accessBusy, onClick: saveAccess }, t('更新', 'Update'))),
|
|
1290
1290
|
h('div', { className: 'sd-field-hint' }, t('只有 scoped 包(@scope/name)可以设为 private;私有包可能需要付费账户。', 'Only scoped packages can be private; private packages may require a paid account.'))),
|
|
@@ -1644,7 +1644,7 @@ window.__ModuleLoader__.load({
|
|
|
1644
1644
|
danger: true,
|
|
1645
1645
|
confirmLabel: t('删除', 'Delete'),
|
|
1646
1646
|
onConfirm: async () => {
|
|
1647
|
-
await call('github.delete-release', { owner: repo.owner, repo: repo.name, releaseId: release.id })
|
|
1647
|
+
await call('github.delete-release', { owner: repo.owner, repo: repo.name, releaseId: release.id, force: true })
|
|
1648
1648
|
toast(t('Release 已删除(tag 仍保留)', 'Release deleted (tag kept)'), 'ok')
|
|
1649
1649
|
await load()
|
|
1650
1650
|
},
|
|
@@ -1665,7 +1665,7 @@ window.__ModuleLoader__.load({
|
|
|
1665
1665
|
form.open
|
|
1666
1666
|
? h('div', { className: 'sd-inline-form sd-inline-card' },
|
|
1667
1667
|
h('div', { className: 'sd-field-grid' },
|
|
1668
|
-
h(Field, { label: 'Tag' }, h(TextInput, { value: form.tag, placeholder: 'v1.1.
|
|
1668
|
+
h(Field, { label: 'Tag' }, h(TextInput, { value: form.tag, placeholder: 'v1.1.3', onChange: (event) => setForm({ ...form, tag: event.target.value }) })),
|
|
1669
1669
|
h(Field, { label: t('标题', 'Title'), optional: true }, h(TextInput, { value: form.name, onChange: (event) => setForm({ ...form, name: event.target.value }) }))),
|
|
1670
1670
|
h(Field, { label: t('说明', 'Notes'), optional: true },
|
|
1671
1671
|
h('textarea', { className: 'sd-input sd-textarea', rows: 3, value: form.body, onChange: (event) => setForm({ ...form, body: event.target.value }) })),
|
|
@@ -2364,7 +2364,10 @@ window.__ModuleLoader__.load({
|
|
|
2364
2364
|
setResult(value)
|
|
2365
2365
|
setStep(4)
|
|
2366
2366
|
refreshStatus()
|
|
2367
|
-
|
|
2367
|
+
const pending = Array.isArray(value.record?.targets) && value.record.targets.some((target) => target.pending === true)
|
|
2368
|
+
toast(value.ok
|
|
2369
|
+
? pending ? t('npm 已受理,registry 正在同步', 'npm accepted; registry is syncing') : t('发布完成', 'Publish complete')
|
|
2370
|
+
: t('部分目标失败,请查看结果', 'Some targets failed; see results'), value.ok ? 'ok' : 'error')
|
|
2368
2371
|
} catch (error) {
|
|
2369
2372
|
fail(error)
|
|
2370
2373
|
} finally {
|
|
@@ -2529,13 +2532,18 @@ window.__ModuleLoader__.load({
|
|
|
2529
2532
|
h('div', { className: 'sd-result-hero' + (result.ok ? ' is-ok' : ' is-fail') },
|
|
2530
2533
|
h('div', { className: 'sd-result-hero-icon' }, result.ok ? h(Icons.check, null) : h(Icons.warn, null)),
|
|
2531
2534
|
h('div', null,
|
|
2532
|
-
h('div', { className: 'sd-result-hero-title' }, result.ok
|
|
2535
|
+
h('div', { className: 'sd-result-hero-title' }, result.ok
|
|
2536
|
+
? (Array.isArray(result.record.targets) && result.record.targets.some((target) => target.pending === true)
|
|
2537
|
+
? t('已受理 · registry 同步中', 'Accepted · registry syncing')
|
|
2538
|
+
: t('发布完成', 'Published'))
|
|
2539
|
+
: t('部分目标失败', 'Partly failed')),
|
|
2533
2540
|
h('div', { className: 'sd-result-hero-sub' }, `${result.record.package}@${result.record.version} · ${result.record.dryRun ? 'dry run' : formatTime(result.record.at, lang)}`))),
|
|
2534
2541
|
h('div', { className: 'sd-purposes' },
|
|
2535
2542
|
result.record.targets.map((target) => h('div', { key: target.target, className: 'sd-purpose' + (target.ok ? ' is-ok' : ' is-fail') },
|
|
2536
2543
|
h('div', { className: 'sd-purpose-head' },
|
|
2537
2544
|
h('strong', null, target.target),
|
|
2538
|
-
h(Chip, { tone: target.ok ? 'ok' : 'danger' }, target.ok ? 'ok' : 'fail')
|
|
2545
|
+
h(Chip, { tone: target.ok ? 'ok' : 'danger' }, target.ok ? 'ok' : 'fail'),
|
|
2546
|
+
target.pending === true ? h(Chip, { tone: 'warn' }, t('同步中', 'syncing')) : null),
|
|
2539
2547
|
h('div', { className: 'sd-record-links' },
|
|
2540
2548
|
target.url ? h('a', { className: 'sd-link', href: target.url, target: '_blank', rel: 'noopener noreferrer' }, 'npm package') : null,
|
|
2541
2549
|
target.release?.htmlUrl ? h('a', { className: 'sd-link', href: target.release.htmlUrl, target: '_blank', rel: 'noopener noreferrer' }, `Release ${target.release.tag}`) : null,
|
|
@@ -3054,15 +3062,20 @@ window.__ModuleLoader__.load({
|
|
|
3054
3062
|
apply(ctx) {
|
|
3055
3063
|
const locale = ctx.get?.('locale')
|
|
3056
3064
|
if (locale !== null && locale !== undefined) localeService = locale
|
|
3057
|
-
|
|
3065
|
+
ctx.inject(['uiWorkspace'], (scoped) => {
|
|
3066
|
+
hostServices.uiWorkspace = scoped.uiWorkspace
|
|
3067
|
+
return () => {
|
|
3068
|
+
if (hostServices.uiWorkspace === scoped.uiWorkspace) hostServices.uiWorkspace = undefined
|
|
3069
|
+
}
|
|
3070
|
+
})
|
|
3058
3071
|
ctx.inject(['layout'], (scoped) => {
|
|
3059
3072
|
hostServices.layout = scoped.layout
|
|
3060
3073
|
return () => {
|
|
3061
3074
|
if (hostServices.layout === scoped.layout) hostServices.layout = undefined
|
|
3062
3075
|
}
|
|
3063
3076
|
})
|
|
3064
|
-
|
|
3065
|
-
|
|
3077
|
+
ctx.inject(['theme'], (scoped) => {
|
|
3078
|
+
const theme = scoped.theme
|
|
3066
3079
|
const readTheme = () => {
|
|
3067
3080
|
try {
|
|
3068
3081
|
setThemeScheme(theme.getTheme()?.active?.colorScheme)
|
|
@@ -3071,8 +3084,9 @@ window.__ModuleLoader__.load({
|
|
|
3071
3084
|
}
|
|
3072
3085
|
}
|
|
3073
3086
|
readTheme()
|
|
3074
|
-
|
|
3075
|
-
|
|
3087
|
+
const off = scoped.on('theme/change', readTheme)
|
|
3088
|
+
return () => off()
|
|
3089
|
+
})
|
|
3076
3090
|
ctx.effect(() => {
|
|
3077
3091
|
const tag = document.createElement('style')
|
|
3078
3092
|
tag.setAttribute('data-plugin', NS)
|
package/index.js
CHANGED
package/lib/github.js
CHANGED
|
@@ -12,7 +12,7 @@ import { parseGitHubRepo } from './semver.js'
|
|
|
12
12
|
|
|
13
13
|
const DEVICE_CODE_URL = 'https://github.com/login/device/code'
|
|
14
14
|
const ACCESS_TOKEN_URL = 'https://github.com/login/oauth/access_token'
|
|
15
|
-
const USER_AGENT = 'dsh-release-depot/1.1.
|
|
15
|
+
const USER_AGENT = 'dsh-release-depot/1.1.3'
|
|
16
16
|
|
|
17
17
|
export class GitHubError extends Error {
|
|
18
18
|
constructor(message, options = {}) {
|
package/lib/net.js
CHANGED
|
@@ -184,6 +184,20 @@ $sb.ToString()
|
|
|
184
184
|
return undefined
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
function redactProxyUrl(value) {
|
|
188
|
+
if (typeof value !== 'string' || value === '') return null
|
|
189
|
+
try {
|
|
190
|
+
const url = new URL(value)
|
|
191
|
+
if (url.username !== '' || url.password !== '') {
|
|
192
|
+
url.username = ''
|
|
193
|
+
url.password = ''
|
|
194
|
+
}
|
|
195
|
+
return url.href
|
|
196
|
+
} catch {
|
|
197
|
+
return value.replace(/\/\/[^/@]*@/, '//')
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
187
201
|
export class Network {
|
|
188
202
|
/**
|
|
189
203
|
* @param {object} options
|
|
@@ -292,8 +306,8 @@ export class Network {
|
|
|
292
306
|
const proxy = await resolveProxy('registry.npmjs.org', this.config)
|
|
293
307
|
return {
|
|
294
308
|
mode: this.config.proxy,
|
|
295
|
-
proxy: proxy
|
|
296
|
-
envProxy: env.https ?? env.http ?? env.all ?? null,
|
|
309
|
+
proxy: redactProxyUrl(proxy),
|
|
310
|
+
envProxy: redactProxyUrl(env.https ?? env.http ?? env.all ?? null),
|
|
297
311
|
noProxy: parseNoProxy(this.config.noProxy),
|
|
298
312
|
undici: (await loadUndici()) !== null,
|
|
299
313
|
systemCa: this.caCache !== null && this.caCache !== undefined,
|
package/lib/registry.js
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
|
|
30
30
|
export const NPM_REGISTRY = 'https://registry.npmjs.org'
|
|
31
31
|
export const GITHUB_REGISTRY = 'https://npm.pkg.github.com'
|
|
32
|
-
const USER_AGENT = 'dsh-release-depot/1.1.
|
|
32
|
+
const USER_AGENT = 'dsh-release-depot/1.1.3 (npm registry client)'
|
|
33
33
|
|
|
34
34
|
export class RegistryError extends Error {
|
|
35
35
|
constructor(message, options = {}) {
|
|
@@ -371,9 +371,16 @@ export class NpmRegistry {
|
|
|
371
371
|
})
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
374
|
+
let tag = 'latest'
|
|
375
|
+
if (options.tag !== undefined && options.tag !== null && String(options.tag).trim() !== '') {
|
|
376
|
+
tag = String(options.tag).trim()
|
|
377
|
+
if (!/^[A-Za-z][A-Za-z0-9._-]{0,31}$/.test(tag)) {
|
|
378
|
+
throw new RegistryError(`不是合法的 dist-tag:${tag}`, {
|
|
379
|
+
code: 'ETAGINVALID',
|
|
380
|
+
hint: 'tag 必须以字母开头,只含字母、数字、点、下划线或连字符,最长 32 位。',
|
|
381
|
+
})
|
|
382
|
+
}
|
|
383
|
+
}
|
|
377
384
|
const tarballName = pack.tarballName
|
|
378
385
|
const tarballUrl = joinPath(this.registry, `${name}/-/${tarballName}`)
|
|
379
386
|
const manifest = { ...pack.publishedManifest }
|
|
@@ -414,6 +421,7 @@ export class NpmRegistry {
|
|
|
414
421
|
return {
|
|
415
422
|
ok: true,
|
|
416
423
|
status,
|
|
424
|
+
pending: status === 202,
|
|
417
425
|
registry: this.registry,
|
|
418
426
|
name,
|
|
419
427
|
version,
|
|
@@ -462,8 +470,8 @@ export class NpmRegistry {
|
|
|
462
470
|
/** Change package visibility (npm access set status). */
|
|
463
471
|
async setAccess(name, access) {
|
|
464
472
|
if (!isValidPackageName(name)) throw new RegistryError(`不是合法的包名:${name}`, { code: 'ENAME' })
|
|
465
|
-
const value = access === 'private' || access === 'restricted' ? '
|
|
466
|
-
if (value === '
|
|
473
|
+
const value = access === 'private' || access === 'restricted' ? 'restricted' : 'public'
|
|
474
|
+
if (value === 'restricted' && splitPackageName(name).scope === null) {
|
|
467
475
|
throw new RegistryError('只有 scoped 包可以设为 private', { code: 'EUNSCOPED' })
|
|
468
476
|
}
|
|
469
477
|
await this.request(`/-/package/${escapedPackageName(name)}/access`, {
|
|
@@ -476,11 +484,17 @@ export class NpmRegistry {
|
|
|
476
484
|
|
|
477
485
|
/** The account's token metadata; token values stay masked. */
|
|
478
486
|
async tokenInfo() {
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
487
|
+
const objects = []
|
|
488
|
+
let path = '/-/npm/v1/tokens'
|
|
489
|
+
for (let page = 0; page < 20 && path !== null; page += 1) {
|
|
490
|
+
const { payload } = await this.request(path, {
|
|
491
|
+
context: '读取 npm Token 信息',
|
|
492
|
+
timeoutMs: 20000,
|
|
493
|
+
})
|
|
494
|
+
if (Array.isArray(payload?.objects)) objects.push(...payload.objects)
|
|
495
|
+
const next = payload?.urls?.next
|
|
496
|
+
path = typeof next === 'string' && next !== '' ? next : null
|
|
497
|
+
}
|
|
484
498
|
return objects.map((entry) => ({
|
|
485
499
|
name: typeof entry?.name === 'string' ? entry.name : '',
|
|
486
500
|
token: typeof entry?.token === 'string' ? entry.token : '',
|
|
@@ -601,7 +615,7 @@ export class NpmRegistry {
|
|
|
601
615
|
* a whole-package removal deletes `/<pkg>/-rev/<rev>`, a single-version
|
|
602
616
|
* removal rewrites the packument then deletes the tarball document.
|
|
603
617
|
*/
|
|
604
|
-
async unpublish(name, version) {
|
|
618
|
+
async unpublish(name, version, options = {}) {
|
|
605
619
|
if (!isValidPackageName(name)) throw new RegistryError(`不是合法的包名:${name}`, { code: 'ENAME' })
|
|
606
620
|
let doc
|
|
607
621
|
try {
|
|
@@ -617,6 +631,12 @@ export class NpmRegistry {
|
|
|
617
631
|
throw new RegistryError(`不是合法的版本:${target}`, { code: 'EVERSION' })
|
|
618
632
|
}
|
|
619
633
|
if (target === '' || target === '*' || allVersions.length <= 1) {
|
|
634
|
+
if (options.confirmWhole !== true) {
|
|
635
|
+
throw new RegistryError('删除整个包需要 confirmName 与包名完全一致', {
|
|
636
|
+
code: 'EWHOLECONFIRM',
|
|
637
|
+
hint: 'npm 会把没有版本或仅剩一个版本的删除视为整包删除;请显式确认包名。',
|
|
638
|
+
})
|
|
639
|
+
}
|
|
620
640
|
const rev = doc._rev
|
|
621
641
|
if (typeof rev !== 'string' || rev === '') {
|
|
622
642
|
throw new RegistryError('registry 没有返回 _rev,无法删除整个包', { code: 'EREV' })
|
package/lib/semver.js
CHANGED
|
@@ -28,8 +28,10 @@ export function parseVersion(input) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
/** True when the string is a plain, complete SemVer version. */
|
|
31
|
+
/** True when the string is a plain, complete SemVer version (no v/=/space). */
|
|
32
32
|
export function isValidVersion(input) {
|
|
33
|
+
if (typeof input !== 'string' || input.trim() !== input) return false
|
|
34
|
+
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.test(input)) return false
|
|
33
35
|
return parseVersion(input) !== null
|
|
34
36
|
}
|
|
35
37
|
|
package/lib/service.js
CHANGED
|
@@ -28,7 +28,7 @@ import { ShipDeckStore } from './store.js'
|
|
|
28
28
|
|
|
29
29
|
const TARGETS = ['npm', 'github-packages', 'github-release']
|
|
30
30
|
const CACHE_TTL_MS = 120000
|
|
31
|
-
const USER_AGENT = 'dsh-release-depot/1.1.
|
|
31
|
+
const USER_AGENT = 'dsh-release-depot/1.1.3'
|
|
32
32
|
|
|
33
33
|
export class ShipDeckError extends Error {
|
|
34
34
|
constructor(message, options = {}) {
|
|
@@ -137,7 +137,9 @@ async function readChangelogSection(dir, version) {
|
|
|
137
137
|
try {
|
|
138
138
|
const text = await readFile(join(dir, 'CHANGELOG.md'), 'utf8')
|
|
139
139
|
const lines = text.replace(/^\uFEFF/, '').split(/\r?\n/)
|
|
140
|
-
const
|
|
140
|
+
const escaped = version.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
141
|
+
const heading = new RegExp(`^##\\s+\\[?v?${escaped}\\]?(?:\\s|$)`, 'i')
|
|
142
|
+
const start = lines.findIndex((line) => heading.test(line.trim()))
|
|
141
143
|
if (start === -1) return ''
|
|
142
144
|
const collected = []
|
|
143
145
|
for (let index = start + 1; index < lines.length; index += 1) {
|
|
@@ -151,7 +153,7 @@ async function readChangelogSection(dir, version) {
|
|
|
151
153
|
}
|
|
152
154
|
|
|
153
155
|
/** User-facing release notes: version changelog + install, no local paths. */
|
|
154
|
-
function defaultReleaseBody(pack, targets, changelog) {
|
|
156
|
+
function defaultReleaseBody(pack, targets, changelog, npmAvailable = false) {
|
|
155
157
|
const lines = []
|
|
156
158
|
const notes = typeof changelog === 'string' ? changelog.trim() : ''
|
|
157
159
|
const description = typeof pack.description === 'string' ? pack.description.trim() : ''
|
|
@@ -160,9 +162,11 @@ function defaultReleaseBody(pack, targets, changelog) {
|
|
|
160
162
|
} else if (description !== '') {
|
|
161
163
|
lines.push(description)
|
|
162
164
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
if (npmAvailable) {
|
|
166
|
+
lines.push('', '### Install / 安装', '', '```sh', `npm install ${pack.name}@${pack.version}`, '```')
|
|
167
|
+
if (Array.isArray(targets) && targets.includes('npm')) {
|
|
168
|
+
lines.push('', `- npm: https://www.npmjs.com/package/${pack.name}/v/${pack.version}`)
|
|
169
|
+
}
|
|
166
170
|
}
|
|
167
171
|
return lines.join('\n')
|
|
168
172
|
}
|
|
@@ -187,7 +191,7 @@ function tokenExpiryDate(entry) {
|
|
|
187
191
|
|
|
188
192
|
export class ShipDeck {
|
|
189
193
|
constructor(options) {
|
|
190
|
-
this.version = options.version ?? '1.1.
|
|
194
|
+
this.version = options.version ?? '1.1.3'
|
|
191
195
|
this.network = options.network
|
|
192
196
|
this.store = options.store ?? new ShipDeckStore({ authFile: options.config?.authFile })
|
|
193
197
|
this.config = options.config ?? {}
|
|
@@ -625,6 +629,16 @@ export class ShipDeck {
|
|
|
625
629
|
if (!isValidPackageName(name)) throw new ShipDeckError(`不是合法的包名:${name}`, { code: 'ENAME' })
|
|
626
630
|
const client = this.npmClientOptional(assertOtp(input?.otp))
|
|
627
631
|
const info = await client.packageInfo(name)
|
|
632
|
+
const requestedVersion = typeof input?.version === 'string' && input.version.trim() !== ''
|
|
633
|
+
? input.version.trim()
|
|
634
|
+
: null
|
|
635
|
+
if (requestedVersion !== null) {
|
|
636
|
+
const selected = info.versions.find((version) => version.version === requestedVersion)
|
|
637
|
+
if (selected === undefined) {
|
|
638
|
+
throw new ShipDeckError(`${name} 不存在版本 ${requestedVersion}`, { code: 'ENOVERSION' })
|
|
639
|
+
}
|
|
640
|
+
return { ok: true, ...info, requestedVersion, requested: selected }
|
|
641
|
+
}
|
|
628
642
|
return { ok: true, ...info }
|
|
629
643
|
}
|
|
630
644
|
|
|
@@ -656,6 +670,7 @@ export class ShipDeck {
|
|
|
656
670
|
const version = String(input?.version ?? '')
|
|
657
671
|
const result = await client.setDistTag(name, tag, version)
|
|
658
672
|
this.invalidate('npm:')
|
|
673
|
+
this.invalidate('packages')
|
|
659
674
|
return { ok: true, ...result }
|
|
660
675
|
}
|
|
661
676
|
|
|
@@ -663,6 +678,7 @@ export class ShipDeck {
|
|
|
663
678
|
const client = this.npmClient(assertOtp(input?.otp))
|
|
664
679
|
const result = await client.deleteDistTag(String(input?.name ?? ''), String(input?.tag ?? ''))
|
|
665
680
|
this.invalidate('npm:')
|
|
681
|
+
this.invalidate('packages')
|
|
666
682
|
return { ok: true, ...result }
|
|
667
683
|
}
|
|
668
684
|
|
|
@@ -707,15 +723,16 @@ export class ShipDeck {
|
|
|
707
723
|
|
|
708
724
|
async npmUnpublish(input) {
|
|
709
725
|
const name = String(input?.name ?? '')
|
|
710
|
-
const version = input?.version === undefined || input?.version === null ? '' : String(input.version)
|
|
726
|
+
const version = input?.version === undefined || input?.version === null ? '' : String(input.version).trim()
|
|
711
727
|
if (input?.force !== true) {
|
|
712
728
|
throw new ShipDeckError('删除包或版本属于不可逆操作,需要显式传入 force: true 确认。', { code: 'ECONFIRM' })
|
|
713
729
|
}
|
|
714
|
-
|
|
730
|
+
const wholeRequested = version === '' || version === '*'
|
|
731
|
+
if (wholeRequested && input?.confirmName !== name) {
|
|
715
732
|
throw new ShipDeckError('删除整个包需要 confirmName 与包名完全一致,以防误操作。', { code: 'ECONFIRM' })
|
|
716
733
|
}
|
|
717
734
|
const client = this.npmClient(assertOtp(input?.otp))
|
|
718
|
-
const result = await client.unpublish(name, version)
|
|
735
|
+
const result = await client.unpublish(name, version, { confirmWhole: input?.confirmName === name })
|
|
719
736
|
this.invalidate('npm:')
|
|
720
737
|
this.invalidate('packages')
|
|
721
738
|
return { ok: true, ...result }
|
|
@@ -827,13 +844,15 @@ export class ShipDeck {
|
|
|
827
844
|
|
|
828
845
|
async githubRepos(input = {}) {
|
|
829
846
|
const auth = this.requireGitHub()
|
|
847
|
+
const limit = Math.min(Math.max(Number(input.limit) || 50, 1), 100)
|
|
848
|
+
const cacheKey = `repos:${limit}`
|
|
830
849
|
if (input.refresh !== true) {
|
|
831
|
-
const cached = this.cacheGet(
|
|
850
|
+
const cached = this.cacheGet(cacheKey)
|
|
832
851
|
if (cached !== null) return { ok: true, items: cached, cached: true }
|
|
833
852
|
}
|
|
834
853
|
const client = this.githubClient(auth)
|
|
835
|
-
const items = await client.listRepos({ perPage:
|
|
836
|
-
this.cacheSet(
|
|
854
|
+
const items = await client.listRepos({ perPage: limit })
|
|
855
|
+
this.cacheSet(cacheKey, items)
|
|
837
856
|
return { ok: true, items, cached: false }
|
|
838
857
|
}
|
|
839
858
|
|
|
@@ -909,6 +928,12 @@ export class ShipDeck {
|
|
|
909
928
|
}
|
|
910
929
|
|
|
911
930
|
async githubDeleteRelease(input) {
|
|
931
|
+
if (input?.force !== true) {
|
|
932
|
+
throw new ShipDeckError('删除 Release 属于不可逆操作,需要显式传入 force: true 确认。', { code: 'ECONFIRM' })
|
|
933
|
+
}
|
|
934
|
+
if (input?.deleteTag === true && (typeof input?.tag !== 'string' || input.tag.trim() === '')) {
|
|
935
|
+
throw new ShipDeckError('同时删除 tag 时必须提供 tag 名称。', { code: 'EINVALIDTAG' })
|
|
936
|
+
}
|
|
912
937
|
const client = this.githubClient()
|
|
913
938
|
const owner = String(input?.owner ?? '').trim()
|
|
914
939
|
const repo = String(input?.repo ?? '').trim()
|
|
@@ -1125,14 +1150,18 @@ export class ShipDeck {
|
|
|
1125
1150
|
const releaseName = typeof githubOptions.releaseName === 'string' && githubOptions.releaseName.trim() !== ''
|
|
1126
1151
|
? githubOptions.releaseName.trim()
|
|
1127
1152
|
: `${pack.name} v${pack.version}`
|
|
1153
|
+
const npmResult = results.find((item) => item.target === 'npm')
|
|
1154
|
+
const npmAvailable = targets.includes('npm') && npmResult?.ok === true
|
|
1128
1155
|
const releaseBody = typeof githubOptions.body === 'string' && githubOptions.body.trim() !== ''
|
|
1129
1156
|
? githubOptions.body
|
|
1130
|
-
: defaultReleaseBody(pack, targets, await readChangelogSection(pack.dir, pack.version))
|
|
1157
|
+
: defaultReleaseBody(pack, targets, await readChangelogSection(pack.dir, pack.version), npmAvailable)
|
|
1131
1158
|
|
|
1132
1159
|
if (dryRun) {
|
|
1133
1160
|
const existing = await client.getRepo(owner, repo)
|
|
1134
1161
|
results.push({
|
|
1135
|
-
target,
|
|
1162
|
+
target,
|
|
1163
|
+
ok: existing !== null || githubOptions.create === true,
|
|
1164
|
+
dryRun: true,
|
|
1136
1165
|
owner, repo, branch: branch ?? existing?.default_branch ?? 'main',
|
|
1137
1166
|
releaseTag, create: existing === null,
|
|
1138
1167
|
repoExists: existing !== null,
|
package/lib/tools.js
CHANGED
|
@@ -37,14 +37,15 @@ const ACTIONS = [
|
|
|
37
37
|
function textResult(value, limit = 12000) {
|
|
38
38
|
const summary = typeof value?.summary === 'string' ? value.summary : ''
|
|
39
39
|
const data = value?.data === undefined ? '' : JSON.stringify(value.data, null, 2)
|
|
40
|
-
|
|
40
|
+
const text = `${value?.ok === true ? '' : 'FAILED: '}${summary}${data === '' ? '' : `\n${data}`}`
|
|
41
|
+
return [{ type: 'text', text: text.length > limit ? `${text.slice(0, limit)}\n…(truncated)` : text }]
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
function ok(value, summary) {
|
|
44
45
|
return {
|
|
45
46
|
ok: true,
|
|
46
47
|
summary,
|
|
47
|
-
data:
|
|
48
|
+
data: withoutLocalPaths(value),
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
|
|
@@ -53,7 +54,7 @@ function fail(error) {
|
|
|
53
54
|
return {
|
|
54
55
|
ok: false,
|
|
55
56
|
summary: `${serialized.message}${serialized.hint === '' ? '' : ` 提示:${serialized.hint}`}`,
|
|
56
|
-
data:
|
|
57
|
+
data: withoutLocalPaths(serialized),
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
|
|
@@ -76,7 +77,7 @@ const output = {
|
|
|
76
77
|
properties: {
|
|
77
78
|
ok: { type: 'boolean' },
|
|
78
79
|
summary: { type: 'string' },
|
|
79
|
-
data: { type: '
|
|
80
|
+
data: { type: 'object', additionalProperties: true },
|
|
80
81
|
},
|
|
81
82
|
required: ['ok', 'summary'],
|
|
82
83
|
},
|
|
@@ -187,6 +188,7 @@ function summarizePublish(result) {
|
|
|
187
188
|
if (target.ok === false) return `${target.target}: 失败 — ${target.error?.message ?? '未知错误'}`
|
|
188
189
|
if (target.dryRun === true) return `${target.target}: 预检通过`
|
|
189
190
|
const link = target.url ?? target.release?.htmlUrl ?? target.repoUrl ?? ''
|
|
191
|
+
if (target.pending === true) return `${target.target}: 已受理,registry 同步中${link === '' ? '' : ` — ${link}`}`
|
|
190
192
|
return `${target.target}: 成功${link === '' ? '' : ` — ${link}`}`
|
|
191
193
|
})
|
|
192
194
|
return `${result.ok === true ? '发布成功' : '发布部分失败'}:${record.package}@${record.version}${result.dryRun === true ? '(dry run,未推送)' : ''}\n${lines.join('\n')}`
|
|
@@ -247,12 +249,12 @@ export function createTools(service, agentCtx, config) {
|
|
|
247
249
|
tag: { type: 'string', description: 'Distribution tag for dist-tag actions, e.g. latest, next.' },
|
|
248
250
|
range: { type: 'string', description: 'SemVer range for deprecate, e.g. <1.2.3 or ^2.0.0. Defaults to *.' },
|
|
249
251
|
message: { type: 'string', description: 'Deprecation text; empty string undeprecates.' },
|
|
250
|
-
access: { type: 'string', enum: ['public', '
|
|
252
|
+
access: { type: 'string', enum: ['public', 'restricted'], description: 'Package visibility for set-access. Only scoped packages can be restricted/private.' },
|
|
251
253
|
user: { type: 'string', description: 'npm username for add-owner / remove-owner.' },
|
|
252
254
|
query: { type: 'string', description: 'Search text for the search action.' },
|
|
253
255
|
limit: { type: 'integer', description: 'Result limit for list/search, 1-100.' },
|
|
254
256
|
otp: { type: 'string', description: 'Six-digit npm two-factor code, when the account requires one.' },
|
|
255
|
-
force: { type: 'boolean', description: 'Must be true for unpublish.' },
|
|
257
|
+
force: { type: 'boolean', description: 'Must be true for unpublish or delete-release.' },
|
|
256
258
|
confirmName: { type: 'string', description: 'Must equal the package name when unpublishing a whole package.' },
|
|
257
259
|
},
|
|
258
260
|
required: ['action'],
|
|
@@ -274,8 +276,8 @@ export function createTools(service, agentCtx, config) {
|
|
|
274
276
|
return ok({ items: result.items, warnings: result.warnings, source: result.source }, summary)
|
|
275
277
|
}
|
|
276
278
|
case 'info': {
|
|
277
|
-
const result = await service.npmInfo({ name: args?.name, otp: args?.otp })
|
|
278
|
-
return ok(result, `${result.name} 最新 ${result.latest ?? '?'},共 ${result.versions.length}
|
|
279
|
+
const result = await service.npmInfo({ name: args?.name, version: args?.version, otp: args?.otp })
|
|
280
|
+
return ok(result, `${result.name} 最新 ${result.latest ?? '?'},共 ${result.versions.length} 个版本${result.requestedVersion ? `;已选 ${result.requestedVersion}` : ''}`)
|
|
279
281
|
}
|
|
280
282
|
case 'search': {
|
|
281
283
|
const result = await service.npmSearch({ query: args?.query, limit: args?.limit })
|
|
@@ -289,10 +291,10 @@ export function createTools(service, agentCtx, config) {
|
|
|
289
291
|
const result = await service.npmSetTag({
|
|
290
292
|
name: args?.name,
|
|
291
293
|
tag: args?.tag,
|
|
292
|
-
version: args?.version
|
|
294
|
+
version: args?.version,
|
|
293
295
|
otp: args?.otp,
|
|
294
296
|
})
|
|
295
|
-
return ok(result, `已设置 ${args?.name} 的 ${args?.tag} → ${args?.version
|
|
297
|
+
return ok(result, `已设置 ${args?.name} 的 ${args?.tag} → ${args?.version}`)
|
|
296
298
|
}
|
|
297
299
|
case 'delete-dist-tag': {
|
|
298
300
|
const result = await service.npmDeleteTag({ name: args?.name, tag: args?.tag, otp: args?.otp })
|
|
@@ -323,16 +325,16 @@ export function createTools(service, agentCtx, config) {
|
|
|
323
325
|
}
|
|
324
326
|
case 'add-owner':
|
|
325
327
|
case 'remove-owner': {
|
|
326
|
-
const
|
|
328
|
+
const verb = action === 'add-owner' ? 'add' : 'remove'
|
|
327
329
|
const result = await service.npmChangeOwner({
|
|
328
330
|
name: args?.name,
|
|
329
331
|
user: args?.user,
|
|
330
|
-
action,
|
|
332
|
+
action: verb,
|
|
331
333
|
otp: args?.otp,
|
|
332
334
|
})
|
|
333
335
|
return ok(result, result.unchanged === true
|
|
334
336
|
? `${args?.user} 已经是维护者`
|
|
335
|
-
: `已${
|
|
337
|
+
: `已${verb === 'add' ? '添加' : '移除'}维护者 ${args?.user}`)
|
|
336
338
|
}
|
|
337
339
|
case 'unpublish': {
|
|
338
340
|
const result = await service.npmUnpublish({
|
|
@@ -432,6 +434,8 @@ export function createTools(service, agentCtx, config) {
|
|
|
432
434
|
prerelease: { type: 'boolean', description: 'Mark the release as a prerelease.' },
|
|
433
435
|
releaseId: { type: 'integer', description: 'Release id for delete-release.' },
|
|
434
436
|
deleteTag: { type: 'boolean', description: 'Also delete the git tag when deleting a release.' },
|
|
437
|
+
force: { type: 'boolean', description: 'Must be true for delete-release.' },
|
|
438
|
+
generateNotes: { type: 'boolean', description: 'Let GitHub generate release notes from commits.' },
|
|
435
439
|
assetPath: { type: 'string', description: 'Absolute path of a single file to attach to the release.' },
|
|
436
440
|
assetDir: { type: 'string', description: 'Package directory to pack; its .tgz is attached to the release.' },
|
|
437
441
|
syncMode: { type: 'string', enum: ['replace', 'merge'], description: 'replace mirrors the directory; merge keeps existing files not present locally. Defaults to replace.' },
|
|
@@ -492,6 +496,7 @@ export function createTools(service, agentCtx, config) {
|
|
|
492
496
|
body: args?.body,
|
|
493
497
|
draft: args?.draft === true,
|
|
494
498
|
prerelease: args?.prerelease === true,
|
|
499
|
+
generateNotes: args?.generateNotes === true,
|
|
495
500
|
assetPath,
|
|
496
501
|
assetDir,
|
|
497
502
|
})
|
|
@@ -504,6 +509,7 @@ export function createTools(service, agentCtx, config) {
|
|
|
504
509
|
releaseId: args?.releaseId,
|
|
505
510
|
deleteTag: args?.deleteTag === true,
|
|
506
511
|
tag: args?.tag,
|
|
512
|
+
force: args?.force === true,
|
|
507
513
|
})
|
|
508
514
|
return ok(result, `已删除 release #${result.id}`)
|
|
509
515
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-release-depot",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"description": "Release Depot(发布仓):在 DeepSeek Harness 内登录 npm 与 GitHub,管理包、发布版本、创建 Release,并把同一套发布能力交给 AI 工具调用。",
|
|
@@ -42,11 +42,13 @@
|
|
|
42
42
|
"dsh",
|
|
43
43
|
"cordis",
|
|
44
44
|
"plugin",
|
|
45
|
+
"release-depot",
|
|
45
46
|
"npm",
|
|
46
47
|
"publish",
|
|
47
48
|
"github",
|
|
48
49
|
"release"
|
|
49
50
|
],
|
|
51
|
+
"author": "5115qwq",
|
|
50
52
|
"license": "MIT",
|
|
51
53
|
"repository": {
|
|
52
54
|
"type": "git",
|