skaya
Version:
CLI SDK for full-stack automation: scaffold frontend, backend & blockchain. Future-ready for Web3, integrations, server components & logging.
71 lines (70 loc) • 2.92 kB
JavaScript
;
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.promptComponentType = promptComponentType;
exports.askApiEndpointConfig = askApiEndpointConfig;
const inquirer_1 = __importDefault(require("inquirer"));
const enums_1 = require("../types/enums");
/**
* Prompts user to select component type based on project type
*/
function promptComponentType(projectType) {
return __awaiter(this, void 0, void 0, function* () {
const { componentType } = yield inquirer_1.default.prompt([{
type: "list",
name: "componentType",
message: `Select ${projectType} component type:`,
choices: projectType === enums_1.ProjectType.FRONTEND
? Object.values(enums_1.FrontendComponentType)
: Object.values(enums_1.BackendComponentType)
}]);
return componentType;
});
}
function askApiEndpointConfig() {
return __awaiter(this, void 0, void 0, function* () {
const answers = yield inquirer_1.default.prompt([
{
type: 'number',
name: 'apiId',
message: 'Enter API ID:',
validate: (input) => Number.isInteger(input) ? true : 'Please enter a valid number',
},
{
type: 'confirm',
name: 'withAuth',
message: 'Does this endpoint require auth?',
default: true,
},
{
type: 'input',
name: 'url',
message: 'Enter the API URL:',
validate: (input) => input ? true : 'URL cannot be empty',
},
{
type: 'list',
name: 'method',
message: 'Select the HTTP method:',
choices: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'],
},
]);
return {
apiId: answers.apiId,
withAuth: answers.withAuth,
url: answers.url,
method: answers.method,
};
});
}