coryd.dev/cli/bin/index.js

31 lines
1.4 KiB
JavaScript
Executable file

#!/usr/bin/env node
import { program } from 'commander';
import chalk from 'chalk';
import figlet from 'figlet';
import { initConfig, loadConfig } from '../lib/config.js';
import { downloadAsset } from '../lib/download.js';
import { runRootScript } from '../lib/runScript.js';
import { handleExitError } from '../lib/handlers.js';
import { runJobsMenu } from '../lib/jobs.js';
import { runTasksMenu } from '../lib/tasks/index.js';
process.on('unhandledRejection', (err) => handleExitError(err, 'Unhandled rejection'));
process.on('uncaughtException', (err) => handleExitError(err, 'Uncaught exception'));
program.name('coryd').description('🪄 Run commands, jobs, download things and have fun.').version('3.0.0');
program.command('init').description('Initialize CLI and populate required config.').action(initConfig);
program.command('run [script]').description('Run site scripts and commands.').action(runRootScript);
program.command('tasks').description('Handle repeated tasks.').action(runTasksMenu);
program.command('jobs').description('Trigger jobs and scripts.').action(runJobsMenu);
program.command('download').description('Download, name and store image assets.').action(downloadAsset);
if (process.argv.length <= 2) {
const ascii = figlet.textSync('coryd.dev', { horizontalLayout: 'default' });
console.log(chalk.hex('#3364ff')(ascii));
console.log();
program.outputHelp();
process.exit(0);
}
program.parse(process.argv);