UNPKG

miridev-cli

Version:

Official CLI tool for deploying static sites to miri.dev - Deploy your websites in seconds

115 lines (94 loc) 4.08 kB
const chalk = require('chalk'); const path = require('path'); const { getCurrentUser } = require('../utils/auth'); const { loadConfig } = require('../utils/files'); /** * 상태 확인 명령어 */ async function status() { console.log(chalk.blue.bold('\n📊 miri.dev Status\n')); try { // 1. 사용자 정보 const user = getCurrentUser(); if (user) { console.log(chalk.green('👤 Authentication Status: Logged in')); console.log(` Email: ${user.email}`); console.log(` Plan: ${user.plan || 'basic'}`); console.log(` Login: ${new Date(user.loginAt).toLocaleString()}`); if (user.expiresAt) { const expiryDate = new Date(user.expiresAt); const isExpired = expiryDate < new Date(); console.log(` Expires: ${expiryDate.toLocaleString()} ${isExpired ? chalk.red('(Expired)') : chalk.green('(Valid)')}`); } } else { console.log(chalk.yellow('👤 Authentication Status: Not logged in (Guest mode)')); console.log(chalk.gray(' Run "miridev login" to log in')); } console.log(''); // 2. 프로젝트 설정 const configPath = path.resolve('miri.config.js'); try { const config = await loadConfig(configPath); if (Object.keys(config).length > 0) { console.log(chalk.green('⚙️ Project Configuration: Found')); if (config.site?.name) { console.log(` Site name: ${config.site.name}`); } if (config.site?.customDomain) { console.log(` Custom domain: ${config.site.customDomain}`); } if (config.build?.command) { console.log(` Build command: ${config.build.command}`); console.log(` Build directory: ${config.build.directory || '.'}`); } if (config.deploy?.ignore?.length > 0) { console.log(` Ignore patterns: ${config.deploy.ignore.length} configured`); } } else { console.log(chalk.yellow('⚙️ Project Configuration: Empty config file')); console.log(chalk.gray(' Run "miridev init" to set up configuration')); } } catch (error) { console.log(chalk.yellow('⚙️ Project Configuration: Not found')); console.log(chalk.gray(' Run "miridev init" to create configuration')); } console.log(''); // 3. 프로젝트 정보 console.log(chalk.cyan('📁 Project Information:')); console.log(` Directory: ${process.cwd()}`); console.log(` Config file: ${configPath}`); // package.json 확인 try { const fs = require('fs-extra'); if (await fs.pathExists('package.json')) { const packageJson = JSON.parse(await fs.readFile('package.json', 'utf8')); console.log(` Package: ${packageJson.name || 'unnamed'} v${packageJson.version || '0.0.0'}`); if (packageJson.scripts?.build) { console.log(` Build script: ${packageJson.scripts.build}`); } } } catch (error) { // package.json 없음 또는 파싱 실패 } // 4. index.html 확인 const fs = require('fs-extra'); const hasIndex = await fs.pathExists('index.html'); console.log(` index.html: ${hasIndex ? chalk.green('✓ Found') : chalk.red('✗ Not found')}`); console.log(''); // 5. 마지막 배포 정보 (향후 구현) console.log(chalk.gray('🚀 Last Deployment: Not available yet')); console.log(chalk.gray(' This feature will be available in a future update')); console.log(''); // 6. 도움말 console.log(chalk.gray('💡 Quick commands:')); console.log(chalk.gray(' miridev deploy Deploy current project')); console.log(chalk.gray(' miridev init Initialize configuration')); console.log(chalk.gray(' miridev login Login to your account')); console.log(chalk.gray(' miridev sites List your sites')); } catch (error) { console.error(chalk.red.bold('\n✗ Failed to check status:')); console.error(chalk.red(error.message)); process.exit(1); } } module.exports = status;