Skip to content

feat: skip package manager prompt when nothing needs installing - #1195

Open
jycouet wants to merge 3 commits into
version-1from
feat/install-when-needed
Open

feat: skip package manager prompt when nothing needs installing#1195
jycouet wants to merge 3 commits into
version-1from
feat/install-when-needed

Conversation

@jycouet

@jycouet jycouet commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Closes #1088

sv add now only asks which package manager to use when an add-on actually adds or widens a dependency in package.json (e.g. sv add mcp=ide:claude-code+setup:remote needs nothing installed). Files are still formatted when the install is skipped for that reason.

Adds isRangeWithin to @sveltejs/sv-utils, so an existing stricter range (^9.2.0 vs a requested ^9.0.0) is kept and doesn't trigger an install.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Jul 25, 2026

Copy link
Copy Markdown

Install the latest version of sv from 57085d3:

pnpm add https://pkg.svelte.dev/sv/c/57085d36e0863c0b5711cc05237e2355f1285307

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/cli/pr/1195

@changeset-bot

changeset-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 57085d3

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

This PR includes changesets to release 2 packages
Name Type
@sveltejs/sv-utils Patch
sv 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

@jycouet
jycouet force-pushed the feat/install-when-needed branch from e072bab to a883eb7 Compare July 25, 2026 17:07
@svelte-docs-bot

Copy link
Copy Markdown

@sacrosanctic

Copy link
Copy Markdown
Contributor

Darn, I was working on the issue too, but yours look better.

Comment on lines +693 to +697
let packageManager: AgentName | null | undefined = null;
if (options.install !== false && installNeeded) {
packageManager =
options.install === true ? await packageManagerPrompt(options.cwd) : options.install;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
let packageManager: AgentName | null | undefined = null;
if (options.install !== false && installNeeded) {
packageManager =
options.install === true ? await packageManagerPrompt(options.cwd) : options.install;
}
let packageManager: AgentName | null | undefined = null;
if (options.install === true) {
// prompt user when `package.json` has changed
if (installNeeded) {
packageManager = await packageManagerPrompt(options.cwd);
}
} else if (options.install === false) {
// user choose not to install
} else {
packageManager = options.install;
}

Comment on lines +760 to +761
// still format when the install was skipped only because no new dependency was added
if (packageManager || (!installNeeded && options.install !== false)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

really hard to understand this condition

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.

2 participants