UNPKG

@roots/bud

Version:

Configurable, extensible build tools for modern single and multi-page web applications

53 lines (52 loc) 1.6 kB
import { __decorate } from "tslib"; import { jsx as _jsx } from "@roots/bud-support/jsx-runtime"; import BudCommand from '@roots/bud/cli/commands'; import indent from '@roots/bud/cli/flags/indent'; import { bind } from '@roots/bud-framework/extension/decorators'; import { Command, Option } from '@roots/bud-support/clipanion'; import { render } from '@roots/bud-support/ink/instance'; import logger from '@roots/bud-support/logger'; /** * {@link BudCommand} */ export default class BudReplCommand extends BudCommand { /** * {@link BudCommand.paths} */ static paths = [[`repl`]]; /** * {@link BudCommand.usage} */ static usage = Command.Usage({ category: `debug`, description: `Explore the fully booted bud object`, examples: [[`Explore the fully booted bud object`, `$0 repl`]], }); depth = Option.String(`--depth,-d`, `1`, { description: `recursion depth`, tolerateBoolean: false, }); indent = indent; /** * {@link BudCommand.catch} */ async catch(error) { logger.error(error.message); } /** * {@link BudCommand.execute} */ async execute() { await this.makeBud().catch(logger.warn); if (!this.bud) return; await this.bud?.compiler?.compile(this.bud).catch(error => { throw error; }); const { Repl } = await import(`./Repl.js`); render(_jsx(Repl, { app: this.bud, depth: this.depth, indent: this.indent })); } } __decorate([ bind ], BudReplCommand.prototype, "execute", null);