add --preview-app-port option to serve command
Signed-off-by: Morgan Bentell <mbentell@spotify.com>
This commit is contained in:
@@ -255,6 +255,21 @@ export function registerCommands(program: Command) {
|
||||
'--preview-app-bundle-path <PATH_TO_BUNDLE>',
|
||||
'Preview documentation using another web app',
|
||||
)
|
||||
.option(
|
||||
'--preview-app-port <PORT>',
|
||||
'Port for the preview app to be served on',
|
||||
'3000',
|
||||
)
|
||||
.hook('preAction', command => {
|
||||
if (
|
||||
command.opts().previewAppPort &&
|
||||
!command.opts().previewAppBundlePath
|
||||
) {
|
||||
command.error(
|
||||
'--preview-app-port can only be used together with --preview-app-bundle-path',
|
||||
);
|
||||
}
|
||||
})
|
||||
.action(lazy(() => import('./serve/serve').then(m => m.default)));
|
||||
}
|
||||
|
||||
|
||||
@@ -56,10 +56,6 @@ export default async function serve(opts: OptionValues) {
|
||||
? true
|
||||
: false;
|
||||
|
||||
// TODO: Backstage app port should also be configurable as a CLI option. However, since we bundle
|
||||
// a backstage app, we define app.baseUrl in the app-config.yaml.
|
||||
// Hence, it is complicated to make this configurable.
|
||||
const backstagePort = 3000;
|
||||
const backstageBackendPort = 7007;
|
||||
|
||||
const mkdocsDockerAddr = `http://0.0.0.0:${opts.mkdocsPort}`;
|
||||
@@ -119,9 +115,11 @@ export default async function serve(opts: OptionValues) {
|
||||
);
|
||||
}
|
||||
|
||||
const port = isDevMode ? backstageBackendPort : backstagePort;
|
||||
const port = isDevMode ? backstageBackendPort : opts.previewAppPort;
|
||||
const previewAppPath = getPreviewAppPath(opts);
|
||||
console.log({ previewAppPath });
|
||||
const httpServer = new HTTPServer(
|
||||
getPreviewAppPath(opts),
|
||||
previewAppPath,
|
||||
port,
|
||||
opts.mkdocsPort,
|
||||
opts.verbose,
|
||||
|
||||
Reference in New Issue
Block a user