Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

768 B
Raw Blame
import type { Command } from 'commander'
import { DASHBOARD_PORT } from '../constants.js'
import { detectProject } from '../context.js'
import { hasDashboardApp } from '../dashboard-server.js'
import { openBrowser } from './init.js'

export function registerOpenCommand(program: Command): void {
  program
    .command('open')
    .description('Open the admin dashboard in the browser')
    .action(async () => {
      const ctx = detectProject()
      // A project's own dashboard runs on its Vite server (`spree dev`);
      // without one, the API serves the built-in dashboard.
      const url = hasDashboardApp(ctx.projectDir)
        ? `http://localhost:${DASHBOARD_PORT}`
        : `http://localhost:${ctx.port}/dashboard`
      await openBrowser(url)
    })
}