Context7 Platform -- Up-to-date docs for AI agents
feat: ide confirmation (#1525)
Fahreddin Özcan89b8bf52858a
diff --git a/packages/cli/package.json b/packages/cli/package.jsonindex 46c5f228..1158b8c9 100644--- a/packages/cli/package.json+++ b/packages/cli/package.json@@ -1,6 +1,6 @@{"name": "ctx7",- "version": "0.1.0",+ "version": "0.1.3","description": "Context7 CLI - Manage AI coding skills and documentation context","type": "module","bin": {diff --git a/packages/cli/src/utils/ide.ts b/packages/cli/src/utils/ide.tsindex 30d3159f..c969a58b 100644--- a/packages/cli/src/utils/ide.ts+++ b/packages/cli/src/utils/ide.ts@@ -1,5 +1,5 @@import pc from "picocolors";-import { select, checkbox } from "@inquirer/prompts";+import { select, checkbox, confirm } from "@inquirer/prompts";import { access } from "fs/promises";import { join } from "path";import { homedir } from "os";@@ -95,17 +95,40 @@ export async function promptForInstallTargets(options: AddOptions): Promise<Instif (detected) {const scope: Scope = options.global ? "global" : detected.scope;- return { ides: detected.ides, scopes: [scope] };- }+ const pathMap = scope === "global" ? IDE_GLOBAL_PATHS : IDE_PATHS;+ const baseDir = scope === "global" ? homedir() : process.cwd();++ const paths = detected.ides.map((ide) => join(baseDir, pathMap[ide]));+ const pathList = paths.join("\n");++ log.blank();+ let confirmed: boolean;+ try {+ confirmed = await confirm({+ message: `Install to detected location(s)?\n${pc.dim(pathList)}`,+ default: true,+ });+ } catch {+ return null;+ }++ if (!confirmed) {+ log.warn("Installation cancelled");+ return null;+ }- if (!options.global) {- return { ides: [DEFAULT_CONFIG.defaultIde], scopes: ["project"] };+ return { ides: detected.ides, scopes: [scope] };}+ // No IDE detected - prompt user to select which client(s) to install forlog.blank();+ const scope: Scope = options.global ? "global" : "project";+ const pathMap = scope === "global" ? IDE_GLOBAL_PATHS : IDE_PATHS;+ const baseDir = scope === "global" ? homedir() : process.cwd();+const ideChoices = (Object.keys(IDE_NAMES) as IDE[]).map((ide) => ({- name: `${IDE_NAMES[ide]} ${pc.dim(`(${IDE_PATHS[ide]})`)}`,+ name: `${IDE_NAMES[ide]} ${pc.dim(`(${pathMap[ide]})`)}`,value: ide,checked: ide === DEFAULT_CONFIG.defaultIde,}));@@ -113,7 +136,7 @@ export async function promptForInstallTargets(options: AddOptions): Promise<Instlet selectedIdes: IDE[];try {selectedIdes = await checkbox({- message: "Which clients do you want to install the skill(s) for?",+ message: `Which clients do you want to install the skill(s) for?\n${pc.dim(baseDir)}`,choices: ideChoices,required: true,});@@ -126,9 +149,7 @@ export async function promptForInstallTargets(options: AddOptions): Promise<Instreturn null;}- const selectedScopes: Scope[] = options.global ? ["global"] : ["project"];-- return { ides: selectedIdes, scopes: selectedScopes };+ return { ides: selectedIdes, scopes: [scope] };}export async function promptForSingleTarget(