UNPKG

@diagramers/cli

Version:

Diagramers CLI - Command-line tools for managing Diagramers projects

45 lines 2.52 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.initCommand = initCommand; const project_initializer_1 = require("../services/project-initializer"); const chalk_1 = __importDefault(require("chalk")); function initCommand(program) { program .command('init <template-type> <project-name>') .description('Initialize a new project from the template') .option('-v, --version <version>', 'Specific version of the template to use (e.g., 1.1.17, latest)') .option('-t, --template <template>', 'Template version to use (deprecated, use --version)', 'latest') .option('-y, --yes', 'Skip prompts and use defaults') .action(async (templateType, projectName, options) => { try { console.log(chalk_1.default.blue(`🚀 Initializing new ${templateType} project: ${projectName}`)); // Validate template type if (templateType !== 'api' && templateType !== 'admin') { throw new Error(`Unsupported template type: ${templateType}. Supported types: api, admin`); } // Use --version option, fallback to --template for backwards compatibility const targetVersion = options.version || (options.template && options.template !== 'latest' ? options.template : undefined); if (targetVersion && targetVersion !== 'latest') { console.log(chalk_1.default.yellow(`📌 Using @diagramers/${templateType} version: ${targetVersion}`)); } const initializer = new project_initializer_1.ProjectInitializer(); await initializer.initialize(projectName, { ...options, template: templateType, version: targetVersion }); console.log(chalk_1.default.green(`✅ Project ${projectName} initialized successfully!`)); console.log(chalk_1.default.yellow(`📁 Navigate to the project: cd ${projectName}`)); console.log(chalk_1.default.yellow(`🔧 Install dependencies: npm install`)); console.log(chalk_1.default.yellow(`🚀 Start development: npm start`)); } catch (error) { console.error(chalk_1.default.red(`❌ Failed to initialize project: ${error.message}`)); process.exit(1); } }); } //# sourceMappingURL=init.js.map