UNPKG

sourcecontrol

Version:

A modern TypeScript CLI application for source control

79 lines â€ĸ 5.47 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.displayInitError = exports.displayReinitializationInfo = exports.displayNextSteps = exports.displayRepositoryStructure = exports.displaySuccessMessage = exports.displayHeader = void 0; const repo_1 = require("../../core/repo"); const utils_1 = require("../../utils"); const chalk_1 = __importDefault(require("chalk")); const path_1 = __importDefault(require("path")); const displayHeader = () => { utils_1.display.info('🚀 Source Control Repository Initialization', 'Source Control Repository Initialization'); }; exports.displayHeader = displayHeader; const displaySuccessMessage = (repoPath, options) => { const title = chalk_1.default.bold.green('✅ Repository Created Successfully!'); const details = [ `${chalk_1.default.gray('📍 Location:')} ${chalk_1.default.white(repoPath)}`, `${chalk_1.default.gray('đŸˇī¸ Type:')} ${chalk_1.default.white(options.bare ? 'Bare Repository' : 'Standard Repository')}`, `${chalk_1.default.gray('âš™ī¸ Format:')} ${chalk_1.default.white('Source Control Repository Format v0')}`, `${chalk_1.default.gray('📁 Directory:')} ${chalk_1.default.white('.source/')}`, ].join('\n'); utils_1.display.success(details, title); }; exports.displaySuccessMessage = displaySuccessMessage; const displayRepositoryStructure = () => { const title = chalk_1.default.yellow('📂 Repository Structure Created'); const structure = [ `${chalk_1.default.cyan('📁')} ${chalk_1.default.white('.source/')} ${chalk_1.default.gray('Source control metadata directory')}`, `${chalk_1.default.cyan('đŸ“Ļ')} ${chalk_1.default.white('├── objects/')} ${chalk_1.default.gray('Object storage (blobs, trees, commits)')}`, `${chalk_1.default.cyan('đŸˇī¸')} ${chalk_1.default.white('├── refs/')} ${chalk_1.default.gray('References (branches, tags)')}`, `${chalk_1.default.cyan('📄')} ${chalk_1.default.white('│ ├── heads/')} ${chalk_1.default.gray('Branch references')}`, `${chalk_1.default.cyan('📄')} ${chalk_1.default.white('│ └── tags/')} ${chalk_1.default.gray('Tag references')}`, `${chalk_1.default.cyan('📋')} ${chalk_1.default.white('├── HEAD')} ${chalk_1.default.gray('Current branch pointer')}`, `${chalk_1.default.cyan('âš™ī¸')} ${chalk_1.default.white('├── config')} ${chalk_1.default.gray('Repository configuration')}`, `${chalk_1.default.cyan('📝')} ${chalk_1.default.white('└── description')} ${chalk_1.default.gray('Repository description')}`, ].join('\n'); utils_1.display.highlight(structure, title); }; exports.displayRepositoryStructure = displayRepositoryStructure; const displayNextSteps = () => { const title = chalk_1.default.magenta('đŸŽ¯ Next Steps'); const steps = [ `${chalk_1.default.gray('1.')} ${chalk_1.default.green('sc add <file>')} ${chalk_1.default.gray('Add files to staging area')}`, `${chalk_1.default.gray('2.')} ${chalk_1.default.green('sc commit -m "message"')} ${chalk_1.default.gray('Create your first commit')}`, `${chalk_1.default.gray('3.')} ${chalk_1.default.green('sc status')} ${chalk_1.default.gray('Check repository status')}`, `${chalk_1.default.gray('4.')} ${chalk_1.default.green('sc log')} ${chalk_1.default.gray('View commit history')}`, ].join('\n'); const tip = `${chalk_1.default.blue('💡 Tip:')} Use ${chalk_1.default.green('sc help <command>')} for more information about any command.`; utils_1.display.highlight(steps + '\n\n' + tip, title); }; exports.displayNextSteps = displayNextSteps; const displayReinitializationInfo = (repoPath) => { const message = [ `The directory ${chalk_1.default.white(repoPath)} already contains a source control repository.`, '', `${chalk_1.default.green('✓')} Reinitialized existing repository in ${chalk_1.default.white(path_1.default.join(repoPath, repo_1.SourceRepository.DEFAULT_GIT_DIR))}`, '', `${chalk_1.default.blue('â„šī¸')} No changes were made to the existing repository structure.`, ].join('\n'); utils_1.display.warning(message, chalk_1.default.yellow('âš ī¸ Repository Already Exists')); }; exports.displayReinitializationInfo = displayReinitializationInfo; const displayInitError = (error) => { const title = chalk_1.default.red('❌ Initialization Failed'); const errorDetails = [ `${chalk_1.default.red('📋 Error Details:')}`, ` └─ ${chalk_1.default.white(error.message)}`, '', `${chalk_1.default.yellow('🔧 Troubleshooting:')}`, ` ${chalk_1.default.gray('1.')} Check if you have write permissions to the directory`, ` ${chalk_1.default.gray('2.')} Ensure the directory path is valid`, ` ${chalk_1.default.gray('3.')} Verify that the disk has sufficient space`, ` ${chalk_1.default.gray('4.')} Try running the command with elevated privileges if needed`, ]; utils_1.display.error(errorDetails.join('\n'), title); }; exports.displayInitError = displayInitError; //# sourceMappingURL=init.display.js.map