UNPKG

@alova/wormhole

Version:

More modern openAPI generating solution for alova.js

37 lines (36 loc) 1.42 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.actionInit = actionInit; exports.actionGen = actionGen; const ora_1 = __importDefault(require("ora")); const index_1 = require("../index"); async function actionInit({ type, cwd }) { const spinner = (0, ora_1.default)('Initializing configuration file...').start(); await (0, index_1.createConfig)({ type, projectPath: cwd }); spinner.succeed('alova configuration file is initialized!'); } async function actionGen({ workspace = true, cwd, force, }) { let workspacePaths = [undefined]; if (workspace) { workspacePaths = await (0, index_1.resolveWorkspaces)(cwd); } for (const dir of workspacePaths) { const spinner = (0, ora_1.default)(`Generating...`).start(); const config = await (0, index_1.readConfig)(dir); const results = await (0, index_1.generate)(config, { force, projectPath: cwd, }); results.forEach((result) => { if (result) { spinner.succeed(`workspace \`${dir}\` is generated!`); } else { spinner.fail(`workspace \`${dir}\` is failed, try to force generate with \`alova gen -f\`!`); } }); } }