@t1mmen/srtd
Version:
Supabase Repeatable Template Definitions (srtd): 🪄 Live-reloading SQL templates for Supabase DX. Make your database changes reviewable and migrations maintainable! 🚀
42 lines • 1.35 kB
JavaScript
import chalk from 'chalk';
/**
* Default keyboard shortcuts for watch mode.
* - q: quit watch mode
* - u: toggle showing unchanged templates in header
* - b: trigger build for all pending templates
*/
export const DEFAULT_WATCH_SHORTCUTS = [
{ key: 'q', label: 'quit' },
{ key: 'u', label: 'toggle unchanged' },
{ key: 'b', label: 'build all' },
];
/**
* Renders the watch mode footer with keyboard shortcuts.
*
* Output format:
* ```
* dest: supabase/migrations
* q quit u toggle unchanged b build all
* ```
*
* Keys are rendered dim, labels in normal text, separated by double-space.
* Uses a blank line for spacing instead of a separator line.
*/
export function renderWatchFooter(options) {
const shortcuts = options?.shortcuts ?? DEFAULT_WATCH_SHORTCUTS;
const destination = options?.destination;
// Blank line for spacing (instead of separator)
console.log();
// Render destination if provided
if (destination) {
console.log(chalk.dim(`dest: ${destination}`));
}
// Render shortcuts line (if any)
if (shortcuts.length > 0) {
const shortcutLine = shortcuts
.map(shortcut => `${chalk.dim(shortcut.key)} ${shortcut.label}`)
.join(' '); // Double-space separator
console.log(shortcutLine);
}
}
//# sourceMappingURL=watchFooter.js.map