@diagramers/cli
Version:
Diagramers CLI - Command-line tools for managing Diagramers projects
35 lines • 1.88 kB
JavaScript
;
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('-t, --template <template>', 'Template version to use', '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`);
}
const initializer = new project_initializer_1.ProjectInitializer();
await initializer.initialize(projectName, { ...options, template: templateType });
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