Skip to content

Commit

Permalink
feat(studio): add support for host and port flags (#1573)
Browse files Browse the repository at this point in the history
  • Loading branch information
anubra266 authored Oct 24, 2023
1 parent 42be222 commit 87772c7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/few-ducks-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@pandacss/studio': patch
'@pandacss/dev': patch
---

Add `--host` and `--port` flags to studio.
8 changes: 7 additions & 1 deletion packages/cli/src/cli-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,13 @@ export async function main() {
.command('studio', 'Realtime documentation for your design tokens')
.option('--build', 'Build')
.option('--preview', 'Preview')
.option('--port <port>', 'Port')
.option('--host', 'Host')
.option('-c, --config <path>', 'Path to panda config file')
.option('--cwd <cwd>', 'Current working directory', { default: cwd })
.option('--outdir', 'Output directory for static files')
.action(async (flags: StudioCommandFlags) => {
const { build, preview, outdir, config } = flags
const { build, preview, port, host, outdir, config } = flags

const cwd = resolve(flags.cwd ?? '')

Expand All @@ -294,6 +296,8 @@ export async function main() {
const buildOpts = {
configPath: findConfigFile({ cwd, file: config })!,
outDir: resolve(outdir || ctx.studio.outdir),
port,
host,
}

if (preview) {
Expand All @@ -304,7 +308,9 @@ export async function main() {
await serveStudio(buildOpts)

const note = `use ${colors.reset(colors.bold('--build'))} to build`
const port = `use ${colors.reset(colors.bold('--port'))} for a different port`
logger.log(colors.dim(` ${colors.green('➜')} ${colors.bold('Build')}: ${note}`))
logger.log(colors.dim(` ${colors.green('➜')} ${colors.bold('Port')}: ${port}`))
}
})

Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export interface StudioCommandFlags extends Pick<Config, 'cwd'> {
preview?: boolean
config?: string
outdir?: string
port?: string
host?: boolean
}

export interface AnalyzeCommandFlags {
Expand Down
6 changes: 4 additions & 2 deletions packages/studio/scripts/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { createRequire } from 'node:module'
export type BuildOpts = {
outDir: string
configPath: string
port?: string
host?: boolean
}

const require = createRequire(import.meta.url)
Expand All @@ -23,8 +25,8 @@ export async function buildStudio({ outDir, configPath }: BuildOpts) {
logger.log(stdout)
}

export async function serveStudio({ configPath }: BuildOpts) {
const result = execa(astroBin, ['dev', '--root', appPath], {
export async function serveStudio({ configPath, port, host }: BuildOpts) {
const result = execa(astroBin, ['dev', '--root', appPath, '--port', port ?? '', host ? '--host' : ''], {
stdio: 'inherit',
cwd: appPath,
env: {
Expand Down

3 comments on commit 87772c7

@vercel
Copy link

@vercel vercel bot commented on 87772c7 Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 87772c7 Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

panda-docs – ./website

panda-docs-git-main-chakra-ui.vercel.app
panda-docs.vercel.app
panda-docs-chakra-ui.vercel.app
panda-css.com

@vercel
Copy link

@vercel vercel bot commented on 87772c7 Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

panda-studio – ./

panda-app.vercel.app
panda-studio-git-main-chakra-ui.vercel.app
panda-studio-chakra-ui.vercel.app

Please sign in to comment.