Skip to content

Commit

Permalink
chore: Add --host and --port command options
Browse files Browse the repository at this point in the history
  • Loading branch information
spring-raining committed Jan 14, 2025
1 parent 15c2511 commit a2e2a10
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/commands/build.parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ It is useful that using own viewer that has staging features. (ex: https://vivli
`true to ignore HTTPS errors when Playwright browser opens a new page`,
),
)
.option('--host <host>', 'IP address the server should listen on')
.option('--port <port>', 'port the server should listen on', parseInt)
.option('--no-enable-static-serve', 'disable static file serving')
// TODO: Remove it in the next major version up
.addOption(new Option('--executable-chromium <path>').hideHelp())
Expand Down
2 changes: 2 additions & 0 deletions src/commands/preview.parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ Currently, Firefox and Webkit support preview command only!`,
`true to ignore HTTPS errors when Playwright browser opens a new page`,
),
)
.option('--host <host>', 'IP address the server should listen on')
.option('--port <port>', 'port the server should listen on', parseInt)
.option('--no-open-viewer', 'do not open viewer')
.option('--no-enable-static-serve', 'disable static file serving')
.option('--no-enable-viewer-start-page', 'disable viewer start page')
Expand Down
6 changes: 6 additions & 0 deletions src/config/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export function mergeInlineConfig(
preflightOption,
vite,
viteConfigFile,
host,
port,
...overrideInlineOptions
} = inlineConfig;

Expand Down Expand Up @@ -84,6 +86,10 @@ export function mergeInlineConfig(
preflightOption,
}),
})),
server: {
...pruneObject(task.server ?? {}),
...pruneObject({ host, port }),
},
})),
inlineOptions: {
...pruneObject(inlineOptions),
Expand Down
16 changes: 16 additions & 0 deletions src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,22 @@ export const VivliostyleInlineConfig = v.pipe(
If a falsy value is provided, Vivliostyle CLI ignores the existing Vite config file.
`),
),
host: v.pipe(
v.union([v.boolean(), ValidString]),
v.description($`
IP address the server should listen on.
Set to \`true\` to listen on all addresses.
(default: \`true\` if a PDF build with Docker render mode is required, otherwise \`false\`)
`),
),
port: v.pipe(
v.number(),
v.minValue(0),
v.maxValue(65535),
v.description($`
Port the server should listen on. (default: \`13000\`)
`),
),
}),
),
v.check(
Expand Down

0 comments on commit a2e2a10

Please sign in to comment.