@bushizhanghan/dsh-publish-gate 0.8.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.0
4
+
5
+ - `checkChangelog()`: `changelog-missing-version` (warn), `changelog-no-versions` (warn), `no-changelog` (info).
6
+ The changelog is the only place a user can learn what a version changed; a bump without an entry is silent
7
+ drift, because npm publishes it anyway and the release notes stay one version behind. Headings accept
8
+ `## 1.2.3`, `### [v1.2.3]` and `# v1.2.3`.
9
+ - An `engines-missing` rule was written and then deleted: `no-engines` already existed. Two rules for one
10
+ condition would have reported the same gap twice.
3
11
  ## 0.8.2
4
12
 
5
13
  - `publish_gate_verify` now returns `pending: true` when the wait runs out with the version still invisible.
package/README.md CHANGED
@@ -72,7 +72,7 @@ dsh plugin --profile desktop add @bushizhanghan/dsh-publish-gate
72
72
  | `readme-wrong-package` | README 的安装命令写的是**另一个包名**(从别的插件抄过来没改)。照着装的人装到别的插件上,而且不会报错——那个包真的存在 |
73
73
 
74
74
  ### 值得在发布前知道的(warn / info)
75
- `npm-scope-mismatch`(登录的账号不是包 scope 的所有者,PUT 会 403,而错误里既不说 token 也不说 scope——我为一个 403 花了一小时)、`unscoped-name`(granular token 的 403)、`repo-missing`、`patch-name-unresolvable`(junction 放错层级)、`inject-unused-service`(`inject` 里写了个拼错的服务名,cordis 一直等它,插件静默不激活)、`no-publish-config-access`(scoped 包没写 `publishConfig.access`,只是提醒,因为命令里本来就带 `--access public`)、`publish-config-registry`(`publishConfig.registry` 指到内网 registry,版本发到别人装不到的地方)、`no-readme` / `readme-no-install` / `readme-no-profile`、`license-mismatch`、`no-tests` / `no-test-files` / `no-test-script`、`no-engines`、`bad-repo-url`、`no-git` / `no-gitignore`、`readme-tool-undocumented`(README 没提这个工具)/ `readme-test-count`(README 写的测试数和真实数不一致),以及市场条目的 `market-*` 全系列。
75
+ `npm-scope-mismatch`(登录的账号不是包 scope 的所有者,PUT 会 403,而错误里既不说 token 也不说 scope——我为一个 403 花了一小时)、`unscoped-name`(granular token 的 403)、`repo-missing`、`patch-name-unresolvable`(junction 放错层级)、`inject-unused-service`(`inject` 里写了个拼错的服务名,cordis 一直等它,插件静默不激活)、`no-publish-config-access`(scoped 包没写 `publishConfig.access`,只是提醒,因为命令里本来就带 `--access public`)、`publish-config-registry`(`publishConfig.registry` 指到内网 registry,版本发到别人装不到的地方)、`no-readme` / `readme-no-install` / `readme-no-profile`、`license-mismatch`、`no-tests` / `no-test-files` / `no-test-script`、`no-engines`、`bad-repo-url`、`no-git` / `no-gitignore`、`readme-tool-undocumented`(README 没提这个工具)/ `readme-test-count`(README 写的测试数和真实数不一致)、`changelog-missing-version`(要发的这个版本号在 CHANGELOG 里没有对应标题,npm 照样发,发布说明就永远落后一版)、`changelog-no-versions`(CHANGELOG 里没有版本标题,读者对不上自己装的那版)、`no-changelog`(只是提醒),以及市场条目的 `market-*` 全系列。
76
76
 
77
77
  ### 产物层:npm 到底会发出什么
78
78
 
@@ -216,7 +216,7 @@ dsh plugin --profile desktop add @bushizhanghan/dsh-publish-gate
216
216
  ## 开发
217
217
 
218
218
  ```sh
219
- node --test # 93 个引擎单测
219
+ node --test # 97 个引擎单测
220
220
  node test/integration.test.mjs # 27 条集成断言(9 个真实插件作 fixture)
221
221
  ```
222
222
 
package/lib/engine.js CHANGED
@@ -556,6 +556,56 @@ export function checkDocs(dir) {
556
556
  return out
557
557
  }
558
558
 
559
+ /**
560
+ * The changelog is the only place a user can learn what a version changed, and
561
+ * a version bump without an entry is invisible drift: `npm publish` says
562
+ * nothing, and the release notes stay one version behind forever.
563
+ */
564
+ export function checkChangelog(dir) {
565
+ const out = []
566
+ const json = readPkgJson(dir)
567
+ if (!json?.version) return out
568
+ const file = ['CHANGELOG.md', 'CHANGELOG', 'HISTORY.md'].find((name) => existsSync(join(dir, name)))
569
+ if (!file) {
570
+ out.push(
571
+ F(
572
+ 'no-changelog',
573
+ 'info',
574
+ 'no CHANGELOG.md',
575
+ 'Every published version is permanent, so users need a place to read what changed. This is a nudge, not a defect.',
576
+ 'Add CHANGELOG.md with one `## <version>` heading per release, and put it in `files`.',
577
+ ),
578
+ )
579
+ return out
580
+ }
581
+ const text = safeText(join(dir, file)) || ''
582
+ const headings = [...text.matchAll(/^#{1,3}\s*\[?v?(\d+\.\d+\.\d+)/gm)].map((m) => m[1])
583
+ if (!headings.length) {
584
+ out.push(
585
+ F(
586
+ 'changelog-no-versions',
587
+ 'warn',
588
+ `${file} has no version headings`,
589
+ 'A changelog without `## 1.2.3` headings cannot be matched to a release, so a reader cannot tell which entry belongs to the version they installed.',
590
+ 'Give every release a `## <version>` heading.',
591
+ ),
592
+ )
593
+ return out
594
+ }
595
+ if (!headings.includes(json.version)) {
596
+ out.push(
597
+ F(
598
+ 'changelog-missing-version',
599
+ 'warn',
600
+ `${file} has no entry for ${json.version} (newest heading is ${headings[0]})`,
601
+ 'The version you are about to publish has no changelog entry. npm publishes it anyway, and the notes now describe an older release.',
602
+ `Add a \`## ${json.version}\` section at the top of ${file}.`,
603
+ ),
604
+ )
605
+ }
606
+ return out
607
+ }
608
+
559
609
  // =====================================================================
560
610
  // npm / GitHub / market state
561
611
  // =====================================================================
@@ -2172,6 +2222,7 @@ export function runStaticChecks(dir) {
2172
2222
  ...checkBuildFreshness(dir),
2173
2223
  ...checkDependencies(dir),
2174
2224
  ...checkDocs(dir),
2225
+ ...checkChangelog(dir),
2175
2226
  ...checkTests(dir),
2176
2227
  ...checkNpmState(dir),
2177
2228
  ...checkGitState(dir),
@@ -2200,6 +2251,7 @@ const RULE_ORDER = [
2200
2251
  'publish-served-mismatch', 'publish-served', 'market-empty', 'market-no-url', 'market-url-not-github',
2201
2252
  'market-no-name', 'market-name-shape', 'market-no-category', 'market-bad-category', 'market-no-desc', 'market-no-en', 'market-no-zh', 'unscoped-name', 'no-git', 'no-readme', 'readme-no-install', 'readme-no-profile', 'readme-wrong-package',
2202
2253
  'market-no-repo', 'market-unavailable', 'market-duplicate-entry', 'market-npm-name-collision', 'market-repo-too-new',
2254
+ 'no-changelog', 'changelog-no-versions', 'changelog-missing-version',
2203
2255
  'git-uncommitted', 'git-tag-missing', 'git-tag-elsewhere',
2204
2256
  'readme-tool-undocumented', 'readme-test-count',
2205
2257
  'no-tests', 'no-test-files', 'no-test-script', 'no-engines', 'bad-repo-url', 'no-gitignore',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bushizhanghan/dsh-publish-gate",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
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",