diff --git a/packages/techdocs-cli/serve.sh b/packages/techdocs-cli/serve.sh new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/techdocs-cli/src/commands/index.ts b/packages/techdocs-cli/src/commands/index.ts index e6c82ba7f8..b951699104 100644 --- a/packages/techdocs-cli/src/commands/index.ts +++ b/packages/techdocs-cli/src/commands/index.ts @@ -255,6 +255,21 @@ export function registerCommands(program: Command) { '--preview-app-bundle-path ', 'Preview documentation using another web app', ) + .option( + '--preview-app-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))); } diff --git a/packages/techdocs-cli/src/commands/serve/serve.ts b/packages/techdocs-cli/src/commands/serve/serve.ts index ebb984782c..c99ab178f0 100644 --- a/packages/techdocs-cli/src/commands/serve/serve.ts +++ b/packages/techdocs-cli/src/commands/serve/serve.ts @@ -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,