UNPKG

outfitter

Version:

Command-line tool for equipping your development journey with configurations and fieldguides

52 lines 2.2 kB
import chalk from 'chalk'; import ora from 'ora'; import fsExtra from 'fs-extra'; const { pathExists } = fsExtra; import { join } from 'path'; /** * Checks for available updates or applies updates to fieldguide configurations. * * If the `check` option is true, displays the update status of fieldguides. Otherwise, simulates updating fieldguides and reports the result. * * @param options - Options to control update behavior. If `check` is true, only checks for updates without applying them. * * @remark * Exits the process with code 1 if the fieldguide configuration file is missing. */ export async function updateFieldguides(options) { const cwd = process.cwd(); const configPath = join(cwd, '.outfitter', 'config.json'); if (!(await pathExists(configPath))) { const message = 'No fieldguide configuration found. Run "outfitter fg create" first.'; // Let the top-level CLI handler decide what to do throw new Error(message); } // TODO: validate config schema once implemented if (options.check) { console.log(chalk.cyan('Checking for updates...\n')); // TODO: In real implementation, check against registry console.log(chalk.yellow('⚠') + ' typescript-standards: ' + chalk.green('v1.2.0') + ' → ' + chalk.cyan('v1.3.0')); console.log(chalk.green('✓') + ' react-patterns: up to date'); console.log(chalk.green('✓') + ' testing-standards: up to date'); console.log('\n' + chalk.gray('Run "outfitter fg update" to install updates')); } else { const spinner = ora('Updating fieldguides...').start(); try { // TODO: Actually fetch and update files await new Promise(resolve => setTimeout(resolve, 1500)); // Simulate work spinner.succeed('Fieldguides updated successfully!'); console.log('\n' + chalk.green('Updated:')); console.log(' • typescript-standards: v1.2.0 → v1.3.0'); } catch (error) { spinner.fail('Failed to update fieldguides'); throw error; } } } //# sourceMappingURL=update.js.map