@bushizhanghan/dsh-publish-gate 0.17.0 → 0.19.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,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.19.0
4
+
5
+ - `prerelease-published-as-latest` (warn): a `-beta` / `-rc` version with no `publishConfig.tag`.
6
+ npm publishes to `latest` whatever the suffix says, so `npm i <name>` starts handing everyone an
7
+ unfinished build and nothing warns.
8
+ - `publish-tag-not-latest` (warn): the version is on the registry but `dist-tags.latest` points at an
9
+ older one. That is what `--tag next` does when you meant to release: the release looks shipped and
10
+ is not what anyone installs.
11
+ - README: dropped a made-up `test/…` example path — `readme-path-missing` caught my own prose.
12
+
13
+ ## 0.18.0
14
+
15
+ - `readme-path-missing` (warn): a README that names `test/…`, `lib/…`, `scripts/…` files that no longer
16
+ exist. Rename a file and the README keeps telling people to run something that returns ENOENT;
17
+ nothing else in the repo notices. Only repo-relative paths under directories a plugin owns, so a
18
+ tutorial example is not a finding.
19
+ - Verified over all nine plugins in this workspace: no false positives, all nine still `e0 w0`.
20
+
3
21
  ## 0.17.0
4
22
 
5
23
  - `changelog-not-shipped` (warn): a CHANGELOG.md that exists on disk but is not in the tarball. npm
package/README.md CHANGED
@@ -75,12 +75,14 @@ dsh plugin --profile desktop add @bushizhanghan/dsh-publish-gate
75
75
  | `no-license` | 缺 LICENSE |
76
76
  | `version-taken` | 这个版本已经在 registry 上,再发是 403 |
77
77
  | `version-behind-latest` | 本地版本比 registry 上的 `latest` **旧**。npm 会照收,但 `latest` 继续指向新版本——包上传了,按名字装的人永远拿不到,且没有任何报错 |
78
+ | `publish-tag-not-latest` | 版本已经在 registry 上了,但 `dist-tags.latest` 还指着旧的。`--tag next` 发出去的版本就是这样:看着发出去了,按名字装的人拿到的还是旧的 |
79
+ | `prerelease-published-as-latest` | 版本是 `-beta` / `-rc`,却没写 `publishConfig.tag`。npm 不看后缀,照样发到 `latest`——所有人 `npm i` 装到的都是没做完的构建 |
78
80
  | `registry-unreachable` | registry 回了 500/429 —— 版本检查**没跑**,所以别把它当干净 |
79
81
  | `npm-not-logged-in` | 这台机器上 npm 没有可用登录(`npm whoami` 报 ENEEDAUTH)。`npm publish` 会在 tarball 打好之后才失败 |
80
82
  | `readme-wrong-package` | README 的安装命令写的是**另一个包名**(从别的插件抄过来没改)。照着装的人装到别的插件上,而且不会报错——那个包真的存在 |
81
83
 
82
84
  ### 值得在发布前知道的(warn / info)
83
- `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`(只是提醒)、`changelog-not-shipped`(CHANGELOG 在本地但没进 tarball——npm 只强制带 README 和 LICENSE,你一直更新的那份文件在 registry 页面上看不见),以及市场条目的 `market-*` 全系列。
85
+ `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-path-missing`(README 里点名的仓库内文件路径已经不存在了,照着敲就是 ENOENT)、`readme-tool-undocumented`(README 没提这个工具)/ `readme-test-count`(README 写的测试数和真实数不一致)、`changelog-missing-version`(要发的这个版本号在 CHANGELOG 里没有对应标题,npm 照样发,发布说明就永远落后一版)、`changelog-no-versions`(CHANGELOG 里没有版本标题,读者对不上自己装的那版)、`no-changelog`(只是提醒)、`changelog-not-shipped`(CHANGELOG 在本地但没进 tarball——npm 只强制带 README 和 LICENSE,你一直更新的那份文件在 registry 页面上看不见),以及市场条目的 `market-*` 全系列。
84
86
 
85
87
  ### 产物层:npm 到底会发出什么
86
88
 
@@ -233,7 +235,7 @@ dsh plugin --profile desktop add @bushizhanghan/dsh-publish-gate
233
235
  ## 开发
234
236
 
235
237
  ```sh
236
- node --test # 117 个引擎单测
238
+ node --test # 120 个引擎单测
237
239
  node test/integration.test.mjs # 27 条集成断言(9 个真实插件作 fixture)
238
240
  ```
239
241
 
package/lib/engine.js CHANGED
@@ -191,6 +191,21 @@ export function checkPackageJson(dir) {
191
191
  out.push(F('invalid-version', 'error', `version "${json.version}" is not semver`, 'npm publish rejects it.', 'Use MAJOR.MINOR.PATCH.'))
192
192
  }
193
193
 
194
+
195
+ // npm publishes to `latest` unless told otherwise, and a prerelease version
196
+ // does not change that. `npm i <name>` then resolves to a beta and every user
197
+ // is on an unfinished build; nothing warns, and the author sees a green publish.
198
+ if (json.version && /^\d+\.\d+\.\d+-/.test(json.version) && (!json.publishConfig?.tag || json.publishConfig.tag === 'latest')) {
199
+ out.push(
200
+ F(
201
+ 'prerelease-published-as-latest',
202
+ 'warn',
203
+ `version "${json.version}" is a prerelease but it will be published to \`latest\``,
204
+ 'npm publishes to `latest` by default and a `-beta`/`-rc` suffix does not change that, so `npm i <name>` starts handing everyone an unfinished build.',
205
+ 'Publish with `npm publish --tag next`, or set publishConfig.tag to next.',
206
+ ),
207
+ )
208
+ }
194
209
  // type: module — the whole plugin surface is ESM
195
210
  if (json.type !== 'module') {
196
211
  out.push(
@@ -554,7 +569,29 @@ export function checkDocs(dir) {
554
569
  )
555
570
  }
556
571
  }
557
- }
572
+ // A README that names files by path rots the moment one is renamed: the
573
+ // reader copies the command, gets ENOENT, and nothing in the repo notices.
574
+ // Only repo-relative paths in the directories a plugin actually owns, so a
575
+ // tutorial example does not turn into a finding.
576
+ if (text) {
577
+ const named = new Set()
578
+ for (const m of text.matchAll(/(?:^|[\s`'"(])((?:test|lib|scripts|bin|src)\/[\w./@-]+\.(?:mjs|cjs|js|json|yml|yaml|md))/g)) {
579
+ if (!existsSync(join(dir, m[1]))) named.add(m[1])
580
+ }
581
+ if (named.size) {
582
+ const list = [...named]
583
+ out.push(
584
+ F(
585
+ 'readme-path-missing',
586
+ 'warn',
587
+ `README names ${list.length} path(s) that do not exist`,
588
+ `Whoever copies them gets ENOENT: ${list.slice(0, 4).join(", ")}.`,
589
+ 'Rename them in the README, or restore the files.',
590
+ ),
591
+ )
592
+ }
593
+ }
594
+ }
558
595
  if (!existsSync(join(dir, 'LICENSE'))) {
559
596
  out.push(F('no-license', 'error', 'LICENSE is missing', 'npm warns on publish and the market listing shows an unknown license.', 'Add a LICENSE file (MIT is the ecosystem norm).'))
560
597
  } else {
@@ -745,11 +782,27 @@ export async function checkVersionTaken(name, version, { registry = 'https://reg
745
782
  )
746
783
  }
747
784
 
785
+
786
+ // A publish with `--tag next` leaves `latest` where it was: the new version
787
+ // is on the registry, `npm i <name>` still gets the old one, and nothing
788
+ // fails. The release looks shipped and is not what anyone installs.
789
+ const latestTag = json?.['dist-tags']?.latest
790
+ if (json?.versions?.[version] && latestTag && latestTag !== version) {
791
+ out.push(
792
+ F(
793
+ 'publish-tag-not-latest',
794
+ 'warn',
795
+ `${name}@${version} is published but \`latest\` still points at ${latestTag}`,
796
+ 'Installing by name keeps getting the old version. This is what `--tag next` (or publishConfig.tag) does when you meant to release.',
797
+ `Move it: npm dist-tag add ${name}@${version} latest`,
798
+ ),
799
+ )
800
+ }
748
801
  // npm accepts a publish of an OLDER version without a word. It lands in
749
802
  // `versions`, but `dist-tags.latest` keeps pointing at the newer one, so
750
803
  // anyone installing by name never receives it. The tarball is uploaded and
751
804
  // invisible — which reads exactly like "my update did not reach anyone".
752
- const latest = json?.['dist-tags']?.latest
805
+ const latest = latestTag
753
806
  if (latest && compareVersions(version, latest) < 0) {
754
807
  out.push(
755
808
  F(
@@ -2542,7 +2595,7 @@ export function runStaticChecks(dir) {
2542
2595
  }
2543
2596
 
2544
2597
  const RULE_ORDER = [
2545
- 'missing-file', 'unreadable', 'utf8-bom', 'json-parse', 'yaml-bom', 'invalid-name', 'invalid-version',
2598
+ 'missing-file', 'unreadable', 'utf8-bom', 'json-parse', 'yaml-bom', 'invalid-name', 'invalid-version', 'prerelease-published-as-latest',
2546
2599
  'missing-field', 'not-esm', 'files-omits-lib', 'files-omits-patch', 'no-exports', 'client-without-export', 'client-without-platform',
2547
2600
  'entry-path-missing', 'bundle-patch-not-declared', 'no-publish-config-access', 'private-field-set', 'publish-config-registry',
2548
2601
  'client-file-missing', 'client-no-module-loader', 'client-parse-failed', 'client-load-not-called',
@@ -2559,9 +2612,9 @@ const RULE_ORDER = [
2559
2612
  'undeclared-import', 'dep-in-dev-only', 'unused-dependency',
2560
2613
  'pack-omits-lib', 'pack-omits-patch', 'pack-omits-client', 'pack-oversize', 'pack-omits-readme', 'pack-omits-license', 'pack-ships-secret',
2561
2614
  'pack-unexpected-dir', 'pack-ships-junk', 'pack-script-build', 'pack-unavailable',
2562
- 'no-license', 'license-mismatch', 'version-taken', 'version-behind-latest', 'npm-not-logged-in', 'npm-scope-mismatch', 'npm-whoami-unavailable', 'registry-unreachable', 'publish-not-served',
2615
+ 'no-license', 'license-mismatch', 'version-taken', 'version-behind-latest', 'publish-tag-not-latest', 'npm-not-logged-in', 'npm-scope-mismatch', 'npm-whoami-unavailable', 'registry-unreachable', 'publish-not-served',
2563
2616
  'publish-served-mismatch', 'publish-served', 'market-empty', 'market-no-url', 'market-url-not-github',
2564
- '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',
2617
+ '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', 'readme-path-missing',
2565
2618
  'market-no-repo', 'market-unavailable', 'market-duplicate-entry', 'market-npm-name-collision', 'market-repo-too-new', 'market-release-behind',
2566
2619
  'no-changelog', 'changelog-no-versions', 'changelog-missing-version', 'changelog-not-shipped',
2567
2620
  'git-uncommitted', 'git-tag-missing', 'git-tag-unverified', 'git-tag-elsewhere',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bushizhanghan/dsh-publish-gate",
3
- "version": "0.17.0",
3
+ "version": "0.19.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",