From 59133cb8a3a0886cf404fd60351960a6799df430 Mon Sep 17 00:00:00 2001 From: imccyu Date: Wed, 5 Aug 2026 01:43:33 +0800 Subject: [PATCH] fix(npm): promote dsh after baseline publication --- scripts/publish-npm-baseline.ts | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/scripts/publish-npm-baseline.ts b/scripts/publish-npm-baseline.ts index 040762fd56..92df711f3e 100644 --- a/scripts/publish-npm-baseline.ts +++ b/scripts/publish-npm-baseline.ts @@ -34,6 +34,8 @@ const DEPENDENCY_SECTIONS = [ 'peerDependencies', ] as const const RELEASE_MANIFEST_NAME = 'manifest.json' +const RELEASE_ENTRY_PACKAGE = '@deepseek-ai/dsh' +const LATEST_DIST_TAG = 'latest' const POSIX_WEB_PROBE = String.raw` import errno, os, pty, select, signal, sys, time node, bin_path, cwd, timeout_seconds = sys.argv[1:] @@ -645,14 +647,17 @@ class RegistryPublication { `publish-npm-baseline: already published ${pkg.name}@${this.bundle.manifest.version}`, ) } - this.ensureDistTag(pkg.name) + this.ensureDistTag(pkg.name, this.bundle.manifest.distTag) } + this.ensureDistTag(RELEASE_ENTRY_PACKAGE, LATEST_DIST_TAG) this.verifyRemote() + this.verifyReleaseEntryDistTag() } verify(): void { this.pingRegistry() this.verifyRemote() + this.verifyReleaseEntryDistTag() } private verifyRemote(): void { @@ -664,7 +669,7 @@ class RegistryPublication { if (integrity !== pkg.integrity) { throw new Error(`integrity mismatch: ${pkg.name}@${this.bundle.manifest.version}`) } - const tagVersion = this.remoteDistTag(pkg.name) + const tagVersion = this.remoteDistTag(pkg.name, this.bundle.manifest.distTag) if (tagVersion !== this.bundle.manifest.version) { throw new Error( `${pkg.name}@${this.bundle.manifest.distTag} points to ${tagVersion ?? ''}; ` @@ -679,6 +684,20 @@ class RegistryPublication { ) } + private verifyReleaseEntryDistTag(): void { + const tagVersion = this.remoteDistTag(RELEASE_ENTRY_PACKAGE, LATEST_DIST_TAG) + if (tagVersion !== this.bundle.manifest.version) { + throw new Error( + `${RELEASE_ENTRY_PACKAGE}@${LATEST_DIST_TAG} points to ${tagVersion ?? ''}; ` + + `expected ${this.bundle.manifest.version}`, + ) + } + console.log( + `publish-npm-baseline: verified ${RELEASE_ENTRY_PACKAGE}@${LATEST_DIST_TAG} at ` + + this.bundle.manifest.version, + ) + } + private pingRegistry(): void { const { registry } = this.bundle.manifest this.runner.capture( @@ -723,8 +742,8 @@ class RegistryPublication { return value } - private remoteDistTag(name: string): string | undefined { - const { registry, distTag } = this.bundle.manifest + private remoteDistTag(name: string, distTag: string): string | undefined { + const { registry } = this.bundle.manifest const raw = this.runner.capture( 'npm', ['dist-tag', 'ls', name, `--registry=${registry}`], @@ -734,9 +753,9 @@ class RegistryPublication { return parseDistTagListing(raw, name).get(distTag) } - private ensureDistTag(name: string): void { - if (this.remoteDistTag(name) === this.bundle.manifest.version) return - const { registry, version, distTag } = this.bundle.manifest + private ensureDistTag(name: string, distTag: string): void { + if (this.remoteDistTag(name, distTag) === this.bundle.manifest.version) return + const { registry, version } = this.bundle.manifest this.runner.run( 'npm', ['dist-tag', 'add', `${name}@${version}`, distTag, `--registry=${registry}`],