An open source design system that's fully customizable and agent ready
TypeScript
fix(scripts): require npm 11.15 for trusted-publisher setup; document the new-package flow (#7957)
Cindy Zhangad6782d2c7c4
diff --git a/docs/release.md b/docs/release.mdindex 144c98e482..159177118e 100644--- a/docs/release.md+++ b/docs/release.md@@ -85,21 +85,47 @@ pnpm publish ./packages/<package> \## Trusted-publisher setup-Trust is configured per package and must point at `release.yml`. A new public package-must exist on npm before trust can be registered, so an npm organization owner runs:+Trust is configured per package. It must name `release.yml` and allow direct+`npm publish`. A new public package must exist on npm before trust can be+registered, so once per new package an npm organization owner runs, in their own+terminal (npm opens two-factor prompts in the browser that only the owner can+complete):```shnpm i -g npm@latest+npm --version # 11.15 or laternpm login --registry https://registry.npmjs.orgnode scripts/npm/setup-trusted-publishing.mjsnode scripts/npm/setup-trusted-publishing.mjs \--bootstrap --setup-trust --workflow release.yml```-The default invocation is audit-only. `--bootstrap` claims a missing package name with-a deprecated `0.0.0-bootstrap.0` version under the `bootstrap` dist-tag; it never-publishes `latest`. `--setup-trust` registers `release.yml`. Use `--replace` only when-an existing trust record is intentionally being replaced.+- The default invocation is audit-only.+- `--bootstrap` claims a missing package name with a deprecated+ `0.0.0-bootstrap.0` placeholder under the `bootstrap` dist-tag. npm makes a+ package's first version its `latest`, so a plain install of the package+ resolves to the empty placeholder until the package's first stable release.+- `--setup-trust` registers `release.yml` for `facebook/astryx` with direct+ publish allowed. The script refuses npm older than 11.15: older npm ignores+ the publish permission, creating a publisher that can only stage releases,+ and lists every existing publisher as a conflict.+- Use `--replace` only when an existing trust record is intentionally being+ replaced, never to clear a conflict reported by npm older than 11.15.++Then open the package's trusted-publisher settings on npmjs.com+(`https://www.npmjs.com/package/<name>/access`) and confirm the+`facebook/astryx` `release.yml` entry allows `npm publish`, not only+`npm stage publish`. The same page is the manual path when the script cannot+finish: add a GitHub Actions publisher with owner `facebook`, repository+`astryx`, workflow `release.yml`, no environment, and `npm publish` allowed.++npm expires a new trusted publisher that no publish has validated within 48+hours. The next push to `main` publishes the package's canary and validates it.+If no canary publishes in that window, recreate the publisher.++Registry reads can keep reporting a just-created package as missing for a few+minutes. A re-run of `--bootstrap` in that window gets `409` for the placeholder+version; the name is already claimed, and the script continues to trust setup.The repo pins pnpm 11. The CI Node line must bundle npm 11.5.1 or later for OIDC-publishing; the local trust setup command requires npm 11.10 or later.+publishing; the local trust setup command requires npm 11.15 or later.diff --git a/packages/vega/README.md b/packages/vega/README.mdindex 5ea5094fe6..52b5bd713d 100644--- a/packages/vega/README.md+++ b/packages/vega/README.md@@ -268,16 +268,7 @@ pnpm -F @astryxdesign/vega buildThe committed `private: true` is npm's hard guarantee that no stable publish can ever happen — **do not remove it until the graduation steps below are intentionally taken.**-> **First canary won't publish until the package name is claimed on npm.** npm cannot register OIDC trust for a name that does not yet exist on the registry. An `@astryxdesign` npm org owner must bootstrap it once (this also applies before the first stable publish):->-> ```bash-> npm i -g npm@latest-> npm login --registry https://registry.npmjs.org # must be an @astryxdesign org owner-> pnpm run setup-trusted-publishing # audit — shows what needs bootstrap/trust-> pnpm run setup-trusted-publishing --bootstrap --setup-trust --workflow release.yml-> ```->-> This publishes a deprecated `0.0.0-bootstrap.0` stub to claim the name and registers `release.yml` as the trusted publisher. Until this is done, CI's canary publish for this package will fail.+> **First canary won't publish until the package name is claimed on npm.** npm cannot register OIDC trust for a name that does not yet exist on the registry. An `@astryxdesign` npm org owner must claim the name and register `release.yml` as its trusted publisher once, following [Trusted-publisher setup](https://github.com/facebook/astryx/blob/main/docs/release.md#trusted-publisher-setup) (this also applies before the first stable publish). Until this is done, CI's canary publish for this package will fail.### Graduating to a public stable (`latest`) releasediff --git a/scripts/npm/setup-trusted-publishing.mjs b/scripts/npm/setup-trusted-publishing.mjsindex f341abe9f6..c8a6155a82 100644--- a/scripts/npm/setup-trusted-publishing.mjs+++ b/scripts/npm/setup-trusted-publishing.mjs@@ -237,8 +237,10 @@ async function checkAuth(registry) {}}-// npm >= 11.10 is required for `npm trust github`. The subcommand landed in npm-// 11.5, but upstream trusted-publishing docs (and lexical) pin 11.10+.+// npm >= 11.15 is required. Older npm ignores `--allow-publish`, so the+// publisher it creates may only stage releases and CI's direct publish fails,+// and its `npm trust list` omits permissions, so every existing publisher+// reads as a conflict.async function checkNpmTrustSupport() {let version;try {@@ -248,12 +250,12 @@ async function checkNpmTrustSupport() {return {ok: false, reason: `Unable to determine npm version: ${err}`};}const [major, minor] = version.split('.').map(n => parseInt(n, 10));- if (major < 11 || (major === 11 && minor < 10)) {+ if (major < 11 || (major === 11 && minor < 15)) {return {ok: false,reason:`npm ${version} is too old for 'npm trust github'. ` +- `Upgrade to npm >= 11.10 (\`npm i -g npm@latest\`) and re-run.`,+ `Upgrade to npm >= 11.15 (\`npm i -g npm@latest\`) and re-run.`,};}try {@@ -324,19 +326,34 @@ async function publishStub(pkg, {registry, stubVersion, repo, dryRun}) {console.log(` [dry-run] Would publish ${pkg.name}@${stubVersion}`);return true;}- await execFileAsync(- 'npm',- [- 'publish',- '--registry',- registry,- '--access',- 'public',- '--tag',- 'bootstrap',- ],- {cwd: tmpDir},- );+ try {+ await execFileAsync(+ 'npm',+ [+ 'publish',+ '--registry',+ registry,+ '--access',+ 'public',+ '--tag',+ 'bootstrap',+ ],+ {cwd: tmpDir},+ );+ } catch (err) {+ // 409: this version already exists, which means an earlier run claimed+ // the name. Registry reads can keep answering 404 for a few minutes after+ // a package is created, so a re-run lands here; continue to trust setup.+ if (+ /E409|409 Conflict/.test(`${err.stderr ?? ''}\n${err.message ?? ''}`)+ ) {+ console.log(+ ` ${pkg.name}@${stubVersion} already exists; the name is claimed`,+ );+ return true;+ }+ throw err;+ }console.log(` Published ${pkg.name}@${stubVersion}`);// Best-effort deprecate — the stub is already published (which is what// unblocks trust setup), so a deprecation failure must not fail the run.@@ -598,8 +615,9 @@ async function main() {console.log(`Authenticated to ${registry} as ${authedUser}`);}- // Preflight: npm >= 11.10 with `npm trust` available.- if (setupTrust && !dryRun) {+ // Preflight: npm >= 11.15 with `npm trust` available, before any trust read+ // or write (the trust reads below run whenever this is not a pure dry run).+ if (setupTrust || !dryRun) {const support = await checkNpmTrustSupport();if (!support.ok) {console.error(support.reason);