Skip to content

Simplify auth state handling - #2065

Merged
Andarist merged 15 commits into
mainfrom
simplify-auth-flow
Jun 29, 2026
Merged

Simplify auth state handling#2065
Andarist merged 15 commits into
mainfrom
simplify-auth-flow

Conversation

@Andarist

@Andarist Andarist commented Jun 6, 2026

Copy link
Copy Markdown
Member

No description provided.

@changeset-bot

changeset-bot Bot commented Jun 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ffb133f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@changesets/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Andarist
Andarist force-pushed the tweak/registry-selection branch from a94ac0d to 50a1d8a Compare June 6, 2026 13:18
@Andarist
Andarist force-pushed the simplify-auth-flow branch from 5363c57 to afc609c Compare June 6, 2026 13:20
@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.70968% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.19%. Comparing base (b8222e6) to head (ffb133f).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
packages/cli/src/commands/publish/npm-utils.ts 80.76% 5 Missing ⚠️
...ckages/cli/src/commands/publish/publishPackages.ts 93.75% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2065      +/-   ##
==========================================
+ Coverage   85.52%   87.19%   +1.67%     
==========================================
  Files          66       71       +5     
  Lines        2535     2523      -12     
  Branches      700      676      -24     
==========================================
+ Hits         2168     2200      +32     
+ Misses        337      299      -38     
+ Partials       30       24       -6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Andarist
Andarist marked this pull request as ready for review June 6, 2026 22:17
@Andarist
Andarist force-pushed the tweak/registry-selection branch from 50a1d8a to f508136 Compare June 6, 2026 22:22
@Andarist
Andarist force-pushed the simplify-auth-flow branch from b67ce93 to 45a76cd Compare June 6, 2026 22:22
Comment thread packages/cli/src/commands/publish-plan/getPublishPlan.ts Outdated
Comment thread packages/cli/src/commands/publish/npm-utils.ts Outdated
Comment thread packages/cli/src/commands/publish/npm-utils.ts
Comment on lines 252 to 253
// in the delegated mode we don't need the json output
// as we won't be handling the auth errors

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.

should we split the two modes into functions? i think it would make the flow easier to follow

e.g. publishInteractive, publishNonInteractive?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it's certainly complicated - but I just don't want to refactor this all too much right now

Comment thread packages/cli/src/utils/types.ts Outdated
Comment thread packages/cli/src/commands/publish/publishPackages.ts
Comment thread packages/cli/src/utils/types.ts Outdated
target = packagesByName.get(release.name)!.dir;
} else {
const pkg = packagesByName.get(release.name)!;
// npm, yarn classic and berry don't support `publishConfig.directory` natively.

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.

I'd much prefer we consider removing support of this as this feels non-standard, but we can discuss this later.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I looked into this. There are situations and tools that require supporting this. If we'd drop this, we would just break the compatibility with them and I don't think it's particularly worth it.

Comment on lines +123 to +127
// However, there are still 2 reasons why we prefer to set it to the root:
// 1. it's a consistent approach that works across package managers and it's also a good location when publishing packed artifacts
// 2. it's important not to call npm from a directory that is an actual workspace (as per the workspaces configuration) and not from, for example, publishConfig.directory
// because npm only resolves to the root's .npmrc for actual workspaces and not for arbitrary subdirectories of the root.
cwd: packages.rootDir,

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.

I would really prefer we call in the workspace directory instead. I don't think no1 is really important as it's a poor implementation from old npm versions. no2 I don't think is an issue if we use pkg.dir here?

Also typo?

Suggested change
// However, there are still 2 reasons why we prefer to set it to the root:
// 1. it's a consistent approach that works across package managers and it's also a good location when publishing packed artifacts
// 2. it's important not to call npm from a directory that is an actual workspace (as per the workspaces configuration) and not from, for example, publishConfig.directory
// because npm only resolves to the root's .npmrc for actual workspaces and not for arbitrary subdirectories of the root.
cwd: packages.rootDir,
// However, there are still 2 reasons why we prefer to set it to the root:
// 1. it's a consistent approach that works across package managers and it's also a good location when publishing packed artifacts
// 2. it's important to call npm from a directory that is an actual workspace (as per the workspaces configuration) and not from, for example, publishConfig.directory
// because npm only resolves to the root's .npmrc for actual workspaces and not for arbitrary subdirectories of the root.
cwd: packages.rootDir,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I juggled this so we call it with cwd: pkg.dir

Comment thread packages/cli/src/commands/publish/publishPackages.ts Outdated
Comment thread packages/cli/package.json
@Andarist
Andarist force-pushed the tweak/registry-selection branch from f508136 to 28857c1 Compare June 21, 2026 09:53
Base automatically changed from tweak/registry-selection to main June 21, 2026 21:50
@Andarist
Andarist force-pushed the simplify-auth-flow branch from 45a76cd to 7cdb754 Compare June 21, 2026 21:53
@Andarist
Andarist force-pushed the simplify-auth-flow branch from 7cdb754 to 3b9c86b Compare June 23, 2026 21:22

@beeequeue beeequeue 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.

this is still way too complicated for my liking...

i would love to extract all the logic into PM-specific utilities to help organize it better, in a later PR

@Andarist
Andarist enabled auto-merge June 29, 2026 09:53
@Andarist
Andarist added this pull request to the merge queue Jun 29, 2026
Merged via the queue into main with commit 0598e83 Jun 29, 2026
12 checks passed
@Andarist
Andarist deleted the simplify-auth-flow branch June 29, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants