feat: exclude deprecated and prerelease versions from completion + add config#27
Conversation
280d977 to
8a37d2b
Compare
📝 WalkthroughWalkthroughAdds a new boolean configuration Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
|
Wow! Excellent idea.
I think filtering out deprecated versions directly is perfectly fine. If someone requests to see them, we can always provide an option for that time — but I doubt anyone would intentionally select a deprecated version when updating, right? 🤔 |
package.json
Outdated
| "default": "provenance-only", | ||
| "description": "Version completion behavior" | ||
| }, | ||
| "npmx.completion.showPrerelease": { |
There was a problem hiding this comment.
Could we place this option under the version level? For example: npmx.completion.version.prelease.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
I appreciate the forward-thinking!
However, I feel that exposing 3 separate boolean flags just for version completion might be a bit too verbose/complex for the user.
I’d prefer a simpler Enum + Boolean pattern:
npmx.completion.version: Enum (Controls the source/strategy, e.g., "all" vs "provenance")
npmx.completion.excludePrerelease: Boolean (Independent filter)
This keeps the config clean while still covering the necessary logic. Since we're in preview, keeping the API surface small seems like a safer bet. WDYT?
There was a problem hiding this comment.
npmx.completion.version: Enum (Controls the source/strategy, e.g., "all" vs "provenance")
npmx.completion.excludePrerelease: Boolean (Independent filter)
I like this, not too verbose and easy to expand
d82397f to
b89f592
Compare
src/constants.ts
Outdated
| export const PNPM_WORKSPACE_PATTERN = `**/${PNPM_WORKSPACE_BASENAME}` | ||
|
|
||
| export const VERSION_TRIGGER_CHARACTERS = [':', '^', '~', '.', ...Array.from({ length: 10 }).map((_, i) => `${i}`)] | ||
| export const PRERELEASE_PATTERN = /-(?:alpha|beta|rc|canary)/i |
There was a problem hiding this comment.
The PRERELEASE_PATTERN seems a bit too restrictive.
Using a whitelist (alpha|beta|rc|canary) will miss many common prerelease tags, such as next (e.g., vue@next), dev, or nightly.
Suggestion: Since SemVer defines a prerelease as anything following a hyphen, a generic regex would be safer:
// Matches any version containing a hyphen
export const PRERELEASE_PATTERN = /-.+/;(Or use semver.prerelease() if the package is available.)

Resolves #25
Config option:

Default disabled:

Excludes deprecated versions completely. @9romise Do you think we need an option to show those as well?