@bushizhanghan/dsh-publish-gate 0.8.1 → 0.8.2
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 +6 -0
- package/README.md +2 -1
- package/lib/engine.js +7 -1
- package/lib/index.js +3 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.2
|
|
4
|
+
|
|
5
|
+
- `publish_gate_verify` now returns `pending: true` when the wait runs out with the version still invisible.
|
|
6
|
+
Measured on 0.8.1 itself: the version appeared **four minutes** after `npm publish`, so one call cannot
|
|
7
|
+
outwait it — the cap is 90 s because the host kills a tool call at 120 s. `pending` says "run it again",
|
|
8
|
+
which is a different answer from "the registry holds different bytes".
|
|
3
9
|
## 0.8.1
|
|
4
10
|
|
|
5
11
|
- `publish_gate_verify` gained `waitMs` (capped at 90 s) and reports `waitedMs`. npm answers 202 and keeps
|
package/README.md
CHANGED
|
@@ -207,6 +207,7 @@ dsh plugin --profile desktop add @bushizhanghan/dsh-publish-gate
|
|
|
207
207
|
- **产物层用 `npm pack --dry-run`,不用自己推 `files` 规则**:npm 的入包规则(`main` / `exports` 强制入包、README/LICENSE 强制入包、`.npmignore` 优先级)比自己实现的准。唯一的代价是它需要这台机器上有 npm,所以跑不起来时降级成 `pack-unavailable` 而不是报错。
|
|
208
208
|
- **运行时层真的执行插件代码**:这是唯一能回答「装上能不能用」的办法。代价是 `apply()` 会跑,所以:假 ctx 是 Proxy 不落盘、20 秒硬超时、`skipTools` 一键跳过。
|
|
209
209
|
- **`--ignore-scripts`**:dry run 不跑 `prepack`,否则检查会触发一次构建。代价是清单可能和真实产物不同,所以有 `pack-script-build` 把这件事说出来。
|
|
210
|
+
- **发完那几十秒不算失败**:npm 收下包会先回 202,然后六十秒到几分钟里这个版本在 registry 上根本不存在。这个插件自己的 0.8.1 实测是**四分钟**才出现。所以 `publish_gate_verify` 加了 `waitMs` 轮询;一轮等不到就返回 `pending: true`——那是「还没轮到」,不是「没发成功」。单次最多等 90 秒,因为宿主 120 秒就掐掉工具调用,剩下的只能再跑一次。
|
|
210
211
|
- **`publish_gate_verify` 比 shasum,不比版本号**:版本号相同而字节不同(发了又改、或本地根本没发)是最常见的自欺。`npm pack --dry-run` 的 shasum 和 registry 的 `dist.shasum` 是同一套算法,所以这个比较是精确的。
|
|
211
212
|
- **只读**:修不修由你定,每条 finding 都带 `fix` 文案。门禁的职责是把话说清楚,不是替你做决定——所以没有 `--fix`。
|
|
212
213
|
- **确定性**:全部规则是文件内容、子进程或 registry/GitHub API 检查,没有 LLM 调用——一条规则答错,你可以直接看规则。
|
|
@@ -215,7 +216,7 @@ dsh plugin --profile desktop add @bushizhanghan/dsh-publish-gate
|
|
|
215
216
|
## 开发
|
|
216
217
|
|
|
217
218
|
```sh
|
|
218
|
-
node --test #
|
|
219
|
+
node --test # 93 个引擎单测
|
|
219
220
|
node test/integration.test.mjs # 27 条集成断言(9 个真实插件作 fixture)
|
|
220
221
|
```
|
|
221
222
|
|
package/lib/engine.js
CHANGED
|
@@ -1936,7 +1936,13 @@ export async function waitForPublished(name, version, localPack, opts = {}) {
|
|
|
1936
1936
|
await new Promise((r) => setTimeout(r, Math.min(intervalMs, waitMs - (Date.now() - started))))
|
|
1937
1937
|
findings = await probe(net)
|
|
1938
1938
|
}
|
|
1939
|
-
|
|
1939
|
+
const served = findings.some((f) => f.rule === 'publish-served')
|
|
1940
|
+
const mismatch = findings.some((f) => f.rule === 'publish-served-mismatch')
|
|
1941
|
+
// `pending` means the wait ran out with the version still invisible — the
|
|
1942
|
+
// normal outcome for a publish npm has not finished processing, NOT a
|
|
1943
|
+
// failure. Measured on this plugin's own 0.8.1: the version appeared four
|
|
1944
|
+
// minutes after `npm publish`, longer than one call can wait.
|
|
1945
|
+
return { findings, waitedMs: Date.now() - started, pending: !served && !mismatch }
|
|
1940
1946
|
}
|
|
1941
1947
|
|
|
1942
1948
|
/** The async half of the gate: everything that needs a subprocess or the network. */
|
package/lib/index.js
CHANGED
|
@@ -199,7 +199,7 @@ export function apply(ctx, config = {}) {
|
|
|
199
199
|
waitMs: {
|
|
200
200
|
type: 'number',
|
|
201
201
|
description:
|
|
202
|
-
'Poll until the registry serves the bytes, up to this many milliseconds (capped at 90000). npm
|
|
202
|
+
'Poll until the registry serves the bytes, up to this many milliseconds (capped at 90000 — the host kills a tool call at 120000). npm answers 202 and keeps the version invisible for 60-180 s after a publish, measured up to 4 minutes, so a single shot reports "not published" on a release that already succeeded. When the wait runs out with `pending: true`, run it again; that is not a failure.',
|
|
203
203
|
},
|
|
204
204
|
},
|
|
205
205
|
},
|
|
@@ -212,7 +212,7 @@ export function apply(ctx, config = {}) {
|
|
|
212
212
|
const { pack, findings: packFindings } = await checkPack(dir)
|
|
213
213
|
if (!pack) return { ok: false, error: `npm pack --dry-run did not run, so there is nothing to compare: ${packFindings.map((f) => f.title).join('; ')}` }
|
|
214
214
|
const waitMs = Math.min(Math.max(0, Number(args.waitMs) || 0), 90_000)
|
|
215
|
-
const { findings, waitedMs } = await waitForPublished(json.name, version, pack, {
|
|
215
|
+
const { findings, waitedMs, pending } = await waitForPublished(json.name, version, pack, {
|
|
216
216
|
registry: cfg.registry,
|
|
217
217
|
timeoutMs: cfg.networkTimeoutMs,
|
|
218
218
|
waitMs,
|
|
@@ -224,6 +224,7 @@ export function apply(ctx, config = {}) {
|
|
|
224
224
|
version,
|
|
225
225
|
published: served || findings.some((f) => f.rule === 'publish-served-mismatch'),
|
|
226
226
|
shasumMatch: served,
|
|
227
|
+
pending,
|
|
227
228
|
localShasum: pack.shasum,
|
|
228
229
|
unpackedSize: pack.unpackedSize,
|
|
229
230
|
files: (pack.files || []).length,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bushizhanghan/dsh-publish-gate",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Pre-publish gate for DSH plugins: manifest, dependencies, artifact, runtime, browser half, traceability and market readiness — plus an input fuzzer that drives every declared parameter with the wrong type. 发布前的七层门禁 + 入参模糊测试。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|