cli-common: polish API surface for run
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -18,7 +18,7 @@ import { OptionValues } from 'commander';
|
||||
import openBrowser from 'react-dev-utils/openBrowser';
|
||||
import { createLogger } from '../../lib/utility';
|
||||
import { runMkdocsServer } from '../../lib/mkdocsServer';
|
||||
import { RunLogFunc } from '@backstage/cli-common';
|
||||
import { RunOnOutput } from '@backstage/cli-common';
|
||||
import { getMkdocsYml } from '@backstage/plugin-techdocs-node';
|
||||
import fs from 'fs-extra';
|
||||
import { checkIfDockerIsOperational } from './utils';
|
||||
@@ -45,7 +45,7 @@ export default async function serveMkdocs(opts: OptionValues) {
|
||||
// We want to open browser only once based on a log.
|
||||
let boolOpenBrowserTriggered = false;
|
||||
|
||||
const logFunc: RunLogFunc = data => {
|
||||
const logFunc: RunOnOutput = data => {
|
||||
// Sometimes the lines contain an unnecessary extra new line in between
|
||||
const logLines = data.toString().split('\n');
|
||||
const logPrefix = opts.docker ? '[docker/mkdocs]' : '[mkdocs]';
|
||||
@@ -80,8 +80,8 @@ export default async function serveMkdocs(opts: OptionValues) {
|
||||
dockerEntrypoint: opts.dockerEntrypoint,
|
||||
dockerOptions: opts.dockerOption,
|
||||
useDocker: opts.docker,
|
||||
stdoutLogFunc: logFunc,
|
||||
stderrLogFunc: logFunc,
|
||||
onStdout: logFunc,
|
||||
onStderr: logFunc,
|
||||
});
|
||||
|
||||
// Keep waiting for user to cancel the process
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import { OptionValues } from 'commander';
|
||||
import path from 'path';
|
||||
import openBrowser from 'react-dev-utils/openBrowser';
|
||||
import { findPaths, RunLogFunc } from '@backstage/cli-common';
|
||||
import { findPaths, RunOnOutput } from '@backstage/cli-common';
|
||||
import HTTPServer from '../../lib/httpServer';
|
||||
import { runMkdocsServer } from '../../lib/mkdocsServer';
|
||||
import { createLogger } from '../../lib/utility';
|
||||
@@ -82,7 +82,7 @@ export default async function serve(opts: OptionValues) {
|
||||
}
|
||||
|
||||
let mkdocsServerHasStarted = false;
|
||||
const mkdocsLogFunc: RunLogFunc = data => {
|
||||
const mkdocsLogFunc: RunOnOutput = data => {
|
||||
// Sometimes the lines contain an unnecessary extra new line
|
||||
const logLines = data.toString().split('\n');
|
||||
const logPrefix = opts.docker ? '[docker/mkdocs]' : '[mkdocs]';
|
||||
@@ -112,8 +112,8 @@ export default async function serve(opts: OptionValues) {
|
||||
dockerEntrypoint: opts.dockerEntrypoint,
|
||||
dockerOptions: opts.dockerOption,
|
||||
useDocker: opts.docker,
|
||||
stdoutLogFunc: mkdocsLogFunc,
|
||||
stderrLogFunc: mkdocsLogFunc,
|
||||
onStdout: mkdocsLogFunc,
|
||||
onStderr: mkdocsLogFunc,
|
||||
mkdocsConfigFileName: mkdocsYmlPath,
|
||||
mkdocsParameterClean: opts.mkdocsParameterClean,
|
||||
mkdocsParameterDirtyReload: opts.mkdocsParameterDirtyreload,
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { run, RunChildProcess, RunLogFunc } from '@backstage/cli-common';
|
||||
import { run, RunChildProcess, RunOnOutput } from '@backstage/cli-common';
|
||||
|
||||
export const runMkdocsServer = (options: {
|
||||
port?: string;
|
||||
@@ -22,8 +22,8 @@ export const runMkdocsServer = (options: {
|
||||
dockerImage?: string;
|
||||
dockerEntrypoint?: string;
|
||||
dockerOptions?: string[];
|
||||
stdoutLogFunc?: RunLogFunc;
|
||||
stderrLogFunc?: RunLogFunc;
|
||||
onStdout?: RunOnOutput;
|
||||
onStderr?: RunOnOutput;
|
||||
mkdocsConfigFileName?: string;
|
||||
mkdocsParameterClean?: boolean;
|
||||
mkdocsParameterDirtyReload?: boolean;
|
||||
@@ -62,8 +62,8 @@ export const runMkdocsServer = (options: {
|
||||
...(options.mkdocsParameterStrict ? ['--strict'] : []),
|
||||
],
|
||||
{
|
||||
stdoutLogFunc: options.stdoutLogFunc,
|
||||
stderrLogFunc: options.stderrLogFunc,
|
||||
onStdout: options.onStdout,
|
||||
onStderr: options.onStderr,
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -82,8 +82,8 @@ export const runMkdocsServer = (options: {
|
||||
...(options.mkdocsParameterStrict ? ['--strict'] : []),
|
||||
],
|
||||
{
|
||||
stdoutLogFunc: options.stdoutLogFunc,
|
||||
stderrLogFunc: options.stderrLogFunc,
|
||||
onStdout: options.onStdout,
|
||||
onStderr: options.onStderr,
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user