UNPKG

skaya

Version:

CLI SDK for full-stack automation: scaffold frontend, backend & blockchain. Future-ready for Web3, integrations, server components & logging.

53 lines (52 loc) 2.69 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleBackendComponentImport = handleBackendComponentImport; const enums_1 = require("../../../../bin/types/enums"); const inquirer_1 = __importDefault(require("inquirer")); const ProjectScanner_1 = require("../../../../bin/utils/ProjectScanner"); function handleBackendComponentImport(componentType) { return __awaiter(this, void 0, void 0, function* () { const existingComponents = yield (0, ProjectScanner_1.scanExistingComponents)(enums_1.ProjectType.BACKEND, componentType); let importExisting = false; let componentsToImport = []; if (existingComponents && existingComponents.length > 0) { const { shouldImport } = yield inquirer_1.default.prompt([ { type: 'confirm', name: 'shouldImport', message: `Would you like to import existing ${componentType} components?`, default: false } ]); if (shouldImport) { const { selectedComponents } = yield inquirer_1.default.prompt([ { type: 'checkbox', name: 'selectedComponents', message: `Use spacebar to select one or more ${componentType} components:`, choices: existingComponents.map((component) => ({ name: component.name, value: component })), pageSize: 10 } ]); componentsToImport = selectedComponents; importExisting = componentsToImport.length > 0; } } return { importExisting, componentsToImport }; }); }