UNPKG

vsix-extension-manager

Version:

VSIX Extension Manager: A comprehensive CLI tool to download, export, import, and manage VS Code/Cursor extensions as VSIX files

325 lines 10.9 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.runInteractive = runInteractive; const p = __importStar(require("@clack/prompts")); async function runInteractive(config) { console.clear(); p.intro("🔽 VSIX Extension Manager"); // Main menu loop to handle back navigation while (true) { const category = await showMainMenu(); if (p.isCancel(category) || category === "quit") { p.cancel("Operation cancelled."); process.exit(0); } // Handle category selection const shouldExit = await handleCategorySelection(category, config); if (shouldExit) { break; } } } /** * Show the main category selection menu */ async function showMainMenu() { return await p.select({ message: "What do you want to do?", options: [ { value: "install", label: "Install", hint: "Install extensions or VSIX files" }, { value: "download", label: "Download", hint: "Download VSIX files" }, { value: "update", label: "Update", hint: "Update installed extensions" }, { value: "export", label: "Export", hint: "Export extension lists" }, { value: "version", label: "Version", hint: "Check extension versions" }, { value: "quit", label: "Quit", hint: "Exit the application" }, ], }); } /** * Handle the selected category and show appropriate sub-menu */ async function handleCategorySelection(category, config) { switch (category) { case "install": return await showInstallMenu(config); case "download": return await showDownloadMenu(config); case "update": return await showUpdateMenu(config); case "export": return await showExportMenu(config); case "version": return await showVersionMenu(config); default: return false; } } /** * Show Install sub-menu */ async function showInstallMenu(config) { const choice = await p.select({ message: "Install Options:", options: [ { value: "quick-install", label: "Quick install by URL", hint: "Temp download → install → cleanup", }, { value: "install-vsix-single", label: "Install single VSIX file", hint: "Install one .vsix file into VS Code/Cursor", }, { value: "install-vsix-dir", label: "Install from directory", hint: "Install all VSIX files from a folder", }, { value: "install-list", label: "Install from list", hint: "Install from .txt or extensions.json file", }, { value: "back", label: "Back to main menu" }, ], }); if (p.isCancel(choice)) { return false; // Go Back to main menu } if (choice === "back") { return false; // Go Back to main menu } // Execute the selected install command await executeInstallCommand(choice, config); return false; // Return to main menu after command execution } /** * Show Download sub-menu */ async function showDownloadMenu(config) { const choice = await p.select({ message: "Download Options:", options: [ { value: "single", label: "Download single extension", hint: "Download from marketplace URL", }, { value: "bulk", label: "Download multiple extensions", hint: "Bulk download from JSON collection", }, { value: "from-list", label: "Download from list", hint: "Download from .txt or extensions.json file", }, { value: "back", label: "Back to main menu" }, ], }); if (p.isCancel(choice)) { return false; // Go Back to main menu } if (choice === "back") { return false; // Go Back to main menu } // Execute the selected download command await executeDownloadCommand(choice, config); return false; // Return to main menu after command execution } /** * Show Update sub-menu */ async function showUpdateMenu(config) { const choice = await p.select({ message: "Update Options:", options: [ { value: "update-installed", label: "Update installed extensions", hint: "Update to latest versions with backup", }, { value: "back", label: "Back to main menu" }, ], }); if (p.isCancel(choice)) { return false; // Go Back to main menu } if (choice === "back") { return false; // Go Back to main menu } // Execute the selected update command await executeUpdateCommand(choice, config); return false; // Return to main menu after command execution } /** * Show Export sub-menu */ async function showExportMenu(config) { const choice = await p.select({ message: "Export Options:", options: [ { value: "export", label: "Export installed extensions", hint: "Export to .txt or extensions.json format", }, { value: "back", label: "Back to main menu" }, ], }); if (p.isCancel(choice)) { return false; // Go Back to main menu } if (choice === "back") { return false; // Go Back to main menu } // Execute the selected export command await executeExportCommand(choice, config); return false; // Return to main menu after command execution } /** * Show Version sub-menu */ async function showVersionMenu(config) { const choice = await p.select({ message: "Version Options:", options: [ { value: "versions", label: "Show extension versions", hint: "List available versions for an extension", }, { value: "back", label: "Back to main menu" }, ], }); if (p.isCancel(choice)) { return false; // Go Back to main menu } if (choice === "back") { return false; // Go Back to main menu } // Execute the selected version command await executeVersionCommand(choice, config); return false; // Return to main menu after command execution } /** * Execute install commands */ async function executeInstallCommand(command, config) { switch (command) { case "quick-install": { const { runQuickInstallUI } = await Promise.resolve().then(() => __importStar(require("./quickInstall"))); await runQuickInstallUI({ ...config }); break; } case "install-vsix-single": { const { runInstallVsixUI } = await Promise.resolve().then(() => __importStar(require("./install"))); await runInstallVsixUI({ ...config }); break; } case "install-vsix-dir": { const { runInstallVsixDirUI } = await Promise.resolve().then(() => __importStar(require("./install"))); await runInstallVsixDirUI({ ...config }); break; } case "install-list": { const { runInstallFromListUI } = await Promise.resolve().then(() => __importStar(require("./install"))); await runInstallFromListUI({ ...config }); break; } } } /** * Execute download commands */ async function executeDownloadCommand(command, config) { switch (command) { case "single": { const { runSingleDownloadUI } = await Promise.resolve().then(() => __importStar(require("./download"))); await runSingleDownloadUI({ ...config }); break; } case "bulk": { const { runBulkJsonDownloadUI } = await Promise.resolve().then(() => __importStar(require("./download"))); await runBulkJsonDownloadUI({ ...config }); break; } case "from-list": { const { fromList } = await Promise.resolve().then(() => __importStar(require("./fromList"))); await fromList({ ...config }); break; } } } /** * Execute update commands */ async function executeUpdateCommand(command, config) { switch (command) { case "update-installed": { const { runUpdateInstalledUI } = await Promise.resolve().then(() => __importStar(require("./updateInstalled"))); await runUpdateInstalledUI({ ...config }); break; } } } /** * Execute export commands */ async function executeExportCommand(command, config) { switch (command) { case "export": { const { exportInstalled } = await Promise.resolve().then(() => __importStar(require("./exportInstalled"))); await exportInstalled({ ...config }); break; } } } /** * Execute version commands */ async function executeVersionCommand(command, config) { switch (command) { case "versions": { const { listVersions } = await Promise.resolve().then(() => __importStar(require("./versions"))); await listVersions({ ...config }); break; } } } //# sourceMappingURL=interactive.js.map