UNPKG

@lunora/cli

Version:

The Lunora CLI: init, dev, deploy, codegen, run, reset, and migrate commands

43 lines (40 loc) 1.27 kB
import { d as defineHandler } from '../packem_shared/command-lYnl4QyF.mjs'; import { o as openUrl } from '../packem_shared/open-url-4PBLY9X0.mjs'; const DEFAULT_DOCS_URL = "https://lunora.anolilab.dev/docs"; const trimSlashes = (value) => { let start = 0; let end = value.length; while (start < end && value[start] === "/") { start += 1; } while (end > start && value[end - 1] === "/") { end -= 1; } return value.slice(start, end); }; const buildUrl = (section) => { if (!section || section.length === 0) { return DEFAULT_DOCS_URL; } const trimmed = trimSlashes(section); if (trimmed.length === 0) { return DEFAULT_DOCS_URL; } return `${DEFAULT_DOCS_URL}/${trimmed}`; }; const runDocsCommand = async (options) => { const url = buildUrl(options.section); options.logger.info(`opening ${url}`); try { await openUrl(url, { opener: options.opener }); } catch (error) { const message = error instanceof Error ? error.message : String(error); options.logger.error(`docs: failed to open URL: ${message}`); return { code: 1, url }; } return { code: 0, url }; }; const execute = defineHandler( ({ argument, logger }) => runDocsCommand({ logger, section: argument[0] }) ); export { execute, runDocsCommand };