Skip to content

Commit c1bf1f4

Browse files
committed
feat(setup:skills): prompt to overwrite existing skills
When running interactively, detect already-installed skills and prompt the user to overwrite them rather than requiring the --update flag up front. Non-interactive behavior (--force, --update, --json) is preserved. Widen isSkillInstalled options to include the optional directory override so the target-path check matches the installer's resolution when --directory is provided.
1 parent 35e9748 commit c1bf1f4

3 files changed

Lines changed: 37 additions & 2 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@salesforce/b2c-cli': patch
3+
'@salesforce/b2c-tooling-sdk': patch
4+
---
5+
6+
`b2c setup skills` now prompts to overwrite already-installed skills in interactive mode instead of silently skipping them with a "use --update to overwrite" message. The existing `--update` and `--force` flags still work non-interactively.

packages/b2c-cli/src/commands/setup/skills.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
downloadSkillsArtifact,
1717
scanSkills,
1818
installSkills,
19+
isSkillInstalled,
1920
getIdeDisplayName,
2021
getIdeDocsUrl,
2122
findSkillsByName,
@@ -305,6 +306,34 @@ export default class SetupSkills extends BaseCommand<typeof SetupSkills> {
305306
}
306307
}
307308

309+
// Detect already-installed skills and prompt to upgrade (unless --update or --force set)
310+
let update = this.flags.update;
311+
if (!update && !this.flags.force) {
312+
const existingCount = skillsToInstall.reduce((count, skill) => {
313+
return (
314+
count +
315+
targetIdes.filter((ide) =>
316+
isSkillInstalled(skill.name, ide, {
317+
global: this.flags.global,
318+
projectRoot: process.cwd(),
319+
directory,
320+
}),
321+
).length
322+
);
323+
}, 0);
324+
325+
if (existingCount > 0) {
326+
update = await confirm({
327+
message: t(
328+
'commands.setup.skills.confirmUpgrade',
329+
'{{count}} skill(s) are already installed. Overwrite with the new version?',
330+
{count: existingCount},
331+
),
332+
default: true,
333+
});
334+
}
335+
}
336+
308337
// Install skills for all skillsets in parallel
309338
const installPromises = skillsets
310339
.map((skillset) => {
@@ -313,7 +342,7 @@ export default class SetupSkills extends BaseCommand<typeof SetupSkills> {
313342
return installSkills(skillsForSet, skillsDirs[skillset], {
314343
ides: targetIdes,
315344
global: this.flags.global,
316-
update: this.flags.update,
345+
update,
317346
projectRoot: process.cwd(),
318347
directory,
319348
});

packages/b2c-tooling-sdk/src/skills/installer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ async function copyDirectory(source: string, target: string): Promise<number> {
8888
export function isSkillInstalled(
8989
skillName: string,
9090
ide: IdeType,
91-
options: {global: boolean; projectRoot?: string},
91+
options: {global: boolean; projectRoot?: string; directory?: string},
9292
): boolean {
9393
const installPath = getSkillInstallPath(ide, skillName, options);
9494
return fs.existsSync(installPath);

0 commit comments

Comments
 (0)