Skip to content

Improve pre-flight npm access checks - #80334

Merged
jsnajdr merged 2 commits into
trunkfrom
adjust-npm-access-command
Jul 29, 2026
Merged

Improve pre-flight npm access checks#80334
jsnajdr merged 2 commits into
trunkfrom
adjust-npm-access-command

Conversation

@desrosj

@desrosj desrosj commented Jul 15, 2026

Copy link
Copy Markdown
Member

What?

This removes the use of npm access list packages @wordpress call in favor of npm access list collaborators <package-name>.

Follow-up to #79904.

Why?

npm access list packages requires the current user or token to possess organization-level read access, which cannot be assigned to organization members (only administrators). npm access list collaborators <package-name> does not require any org-level access and even works for unauthenticated users.

When combined with npm whoami, this effectively replaces the need for any organization privileges to be assigned to a token.

This also expands the pre-flight checks to confirm that the user has the required permissions to publish every dependency that will be published as a part of running the publish command.

Use of AI Tools

Claude Code was used to create the initial PR.

@desrosj
desrosj requested review from ciampo and jsnajdr July 15, 2026 20:09
@desrosj desrosj self-assigned this Jul 15, 2026
@desrosj
desrosj requested a review from manzoorwanijk as a code owner July 15, 2026 20:09
@desrosj desrosj added the [Type] Build Tooling Issues or PRs related to build tooling label Jul 15, 2026

@jsnajdr jsnajdr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'm a bit curious how long it will take to run npm access in loop for 140 packages 🙂

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @myexampl35-dotcom.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: myexampl35-dotcom.

Co-authored-by: desrosj <desrosj@git.wordpress.org>
Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.76 MB

compressed-size-action

@desrosj

desrosj commented Jul 15, 2026

Copy link
Copy Markdown
Member Author

OK, I'm a bit curious how long it will take to run npm access in loop for 140 packages 🙂

That did come to mind. 😅

I ran some testing locally. Across 50 runs of npm access list collaborators @wordpress/block-library the mean time was 1.008s and median time was 0.937s. Just 15 of those 50 requests requests took longer 1 second. So this would add ~2-2.5 minutes to the pre-flight steps.

Another option is to check only the first package, or maybe the first 5 if there's a desire to validate multiple packages. I'm curious what @ciampo prefers given he can speak best to the original intention of these pre-flight checks.

@github-actions

Copy link
Copy Markdown

Flaky tests detected in 68ae21e.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29447226898
📝 Reported issues:

@ciampo

ciampo commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

As also mentioned in Slack, we could drop the npm access check and only keep npm whoami, as it's sufficient to catch invalid/expired/misconfigured credentials.

The npm access command also kind of contradicts the fact that we pass --no-verify-access  when running lerna.

We can keep the npm whoami and the npm view [package]@[version] checks

@jsnajdr

jsnajdr commented Jul 16, 2026

Copy link
Copy Markdown
Member

My preference would be to just check npm whoami. That catches practically all realistic issues that can happen with the token. One step further would be to list collaborators for one @wordpress/* package. That catches an unlikely token that was wrongly issued from the start, with insufficient permissions.

@myexampl35-dotcom myexampl35-dotcom left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tools/release/commands/packages.js

@jsnajdr

jsnajdr commented Jul 29, 2026

Copy link
Copy Markdown
Member

I implemented the npm whoami suggestion and will merge this now: the old npm access command interrupted the 23.7 RC 1 release earlier today.

@jsnajdr
jsnajdr enabled auto-merge (squash) July 29, 2026 18:48
@jsnajdr jsnajdr added the Backport to Gutenberg Minor Release Pull request that needs to be backported to a Gutenberg minor release label Jul 29, 2026
@jsnajdr jsnajdr added this to the Gutenberg 23.7 milestone Jul 29, 2026
@desrosj

desrosj commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

Thanks @jsnajdr! No objections here.

@jsnajdr
jsnajdr merged commit ce7ff77 into trunk Jul 29, 2026
48 checks passed
@jsnajdr
jsnajdr deleted the adjust-npm-access-command branch July 29, 2026 19:18
@jsnajdr

jsnajdr commented Jul 30, 2026

Copy link
Copy Markdown
Member

I just cherry-picked this PR to the release/23.7 branch to get it included in the next release: de2e2d7

jsnajdr added a commit that referenced this pull request Jul 30, 2026
* Improve pre-flight npm access checks.

* use npm whoami for simplicity

---------

Co-authored-by: desrosj <desrosj@git.wordpress.org>
Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
@jsnajdr jsnajdr removed the Backport to Gutenberg Minor Release Pull request that needs to be backported to a Gutenberg minor release label Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Build Tooling Issues or PRs related to build tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants