@re-shell/cli
Version:
Full-stack development platform uniting microservices and microfrontends. Build complete applications with .NET (ASP.NET Core Web API, Minimal API), Java (Spring Boot, Quarkus, Micronaut, Vert.x), Rust (Actix-Web, Warp, Rocket, Axum), Python (FastAPI, Dja
123 lines (122 loc) ⢠5.81 kB
JavaScript
;
/**
* List available backend templates command
*/
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;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.listTemplatesCommand = listTemplatesCommand;
const chalk_1 = __importDefault(require("chalk"));
const backend_template_registry_1 = __importStar(require("../templates/backend/backend-template-registry"));
async function listTemplatesCommand(options = {}) {
console.log(chalk_1.default.bold.blue('\nš Re-Shell Backend Templates\n'));
if (options.stats) {
displayStats();
return;
}
if (options.language) {
// Show templates for specific language
const templates = backend_template_registry_1.default.getByLanguage(options.language);
if (templates.length === 0) {
console.log(chalk_1.default.yellow(`No templates found for language: ${options.language}`));
console.log(chalk_1.default.gray('Available languages:'), backend_template_registry_1.default.getLanguages().join(', '));
return;
}
console.log(chalk_1.default.bold(`${options.language} Templates:`));
console.log('ā'.repeat(60));
for (const template of templates) {
displayTemplate(template, options.verbose);
}
}
else if (options.framework) {
// Search by framework
const templates = backend_template_registry_1.default.searchTemplates(options.framework);
if (templates.length === 0) {
console.log(chalk_1.default.yellow(`No templates found matching: ${options.framework}`));
return;
}
console.log(chalk_1.default.bold(`Templates matching "${options.framework}":`));
console.log('ā'.repeat(60));
for (const template of templates) {
displayTemplate(template, options.verbose);
}
}
else {
// Show all templates grouped by language
(0, backend_template_registry_1.listBackendTemplates)();
}
console.log(chalk_1.default.gray('\nUsage:'));
console.log(chalk_1.default.gray(' re-shell generate backend <name> --template <template-id>'));
console.log(chalk_1.default.gray(' re-shell generate backend user-api --template swift-vapor --port 8080'));
}
function displayTemplate(template, verbose = false) {
const status = template.generator ? chalk_1.default.green('ā
') : chalk_1.default.yellow('š§');
const name = chalk_1.default.cyan(template.name.padEnd(20));
const framework = chalk_1.default.bold(template.framework.padEnd(15));
console.log(`${status} ${name} ${framework} - ${template.description}`);
if (verbose) {
console.log(chalk_1.default.gray(' Features:'));
for (const feature of template.features) {
console.log(chalk_1.default.gray(` ⢠${feature}`));
}
console.log(chalk_1.default.gray(` Default Port: ${template.defaultPort}`));
console.log('');
}
}
function displayStats() {
const stats = (0, backend_template_registry_1.getTemplateStats)();
console.log(chalk_1.default.bold('Template Statistics:'));
console.log('ā'.repeat(60));
console.log(`Total Templates: ${chalk_1.default.cyan(stats.total)}`);
console.log(`Implemented: ${chalk_1.default.green(stats.implemented)} (${Math.round(stats.implemented / stats.total * 100)}%)`);
console.log(`Coming Soon: ${chalk_1.default.yellow(stats.total - stats.implemented)}`);
console.log(`Languages: ${chalk_1.default.blue(stats.languages)}`);
console.log('');
console.log(chalk_1.default.bold('By Language:'));
console.log('ā'.repeat(60));
for (const [language, langStats] of Object.entries(stats.byLanguage)) {
const percentage = Math.round(langStats.implemented / langStats.total * 100);
const progressBar = createProgressBar(percentage, 20);
console.log(`${language.padEnd(15)} ${progressBar} ${chalk_1.default.green(langStats.implemented)}/${langStats.total} (${percentage}%)`);
}
}
function createProgressBar(percentage, width) {
const filled = Math.round((percentage / 100) * width);
const empty = width - filled;
return chalk_1.default.green('ā'.repeat(filled)) + chalk_1.default.gray('ā'.repeat(empty));
}
exports.default = listTemplatesCommand;