UNPKG

@supernovaio/cli

Version:

Supernova.io Command Line Interface

89 lines (87 loc) 3.73 kB
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d0145f7d-abaf-57c7-9cb3-2c47fd02b4b8")}catch(e){}}(); import inquirer from "inquirer"; import path from "node:path"; import { discoverPackagesUnderPath, validateDirectoryPath } from "../../helpers.js"; import { setupTemplateFrameworkValues } from "../../flow/types.js"; import { promptConfirmation } from "../../prompts.js"; import { colorize } from "../../ui.js"; import { promptImplicitCheckbox } from "./implicit-checkbox.js"; export async function promptTemplateFramework(defaultFramework) { const response = await inquirer.prompt([ { choices: setupTemplateFrameworkValues.map(framework => ({ name: framework, value: framework })), default: defaultFramework, message: colorize("Select your framework", "blue"), name: "templateFramework", type: "list", }, ]); return response.templateFramework; } export async function promptScanSourcePath(input) { const scanSourcePath = path.resolve(process.cwd()); while (true) { const shouldProceed = await promptConfirmation("Proceed with scan?"); if (!shouldProceed) { if (!input.allowSkip) { input.error("Setup cancelled during source scan."); } return null; } const validationError = validateDirectoryPath(scanSourcePath); if (validationError) { input.log(validationError); input.error(validationError); } const discoveredPackages = discoverPackagesUnderPath(scanSourcePath); if (discoveredPackages.length > 0) { return { discoveredPackages, scanSourcePath }; } input.log("No package.json files were found under the selected folder."); const action = await inquirer.prompt([ { choices: [ { name: "Retry package discovery", value: "retry" }, ...(input.allowSkip ? [{ name: "Skip scan and continue", value: "skip" }] : []), { name: "Cancel setup", value: "cancel" }, ], default: "retry", message: colorize("Next action:", "yellow"), name: "action", type: "list", }, ]); if (action.action === "skip") return null; if (action.action === "cancel") { input.error("Setup cancelled during source scan."); } } } export async function promptScanPackages(discoveredPackages, defaultPackages, error) { const defaults = new Set(defaultPackages ?? []); const componentPackages = await promptImplicitCheckbox({ choices: discoveredPackages.map(item => ({ checked: defaults.has(item.name), name: `${item.name} (${item.relativePath})`, value: item.name, })), message: colorize("Which packages contain your component libraries?", "blue"), }); if (componentPackages.length === 0) { ; (error ?? ((message) => { throw new Error(message); }))("Select at least one package to continue scanning."); } return componentPackages; } export async function promptContinueSetup(error) { const shouldContinue = await promptConfirmation("Continue setup?"); if (!shouldContinue) { error("Setup cancelled."); } } //# sourceMappingURL=prompts.js.map //# debugId=d0145f7d-abaf-57c7-9cb3-2c47fd02b4b8