fix(techdocs-cli): limit supported mkdocs flags
Signed-off-by: hainenber <dotronghai96@gmail.com>
This commit is contained in:
@@ -91,7 +91,9 @@ Options:
|
||||
--docker-option <DOCKER_OPTION...> Extra options to pass to the docker run command, e.g. "--add-host=internal.host:192.168.11.12"
|
||||
(can be added multiple times).
|
||||
--no-docker Do not use Docker, use MkDocs executable in current user environment.
|
||||
--mkdocs-configs Extra mkdocs server to pass to mkdocs running in containerized environment.
|
||||
--mkdocs-parameter-clean Pass "--clean" parameter to mkdocs server running in containerized environment.
|
||||
--mkdocs-parameter-dirty Pass "--dirty" parameter to mkdocs server running in containerized environment.
|
||||
--mkdocs-parameter-strict Pass "--strict" parameter to mkdocs server running in containerized environment.
|
||||
--mkdocs-port <PORT> Port for MkDocs server to use (default: "8000")
|
||||
--preview-app-bundle-path <PATH_TO_BUNDLE> Preview documentation using a web app other than the included one.
|
||||
--preview-app-port <PORT> Port where the preview will be served.
|
||||
|
||||
@@ -107,6 +107,9 @@ Options:
|
||||
--preview-app-bundle-path <PATH_TO_BUNDLE>
|
||||
--preview-app-port <PORT>
|
||||
-c, --mkdocs-config-file-name <FILENAME>
|
||||
--mkdocs-parameter-clean
|
||||
--mkdocs-parameter-dirty
|
||||
--mkdocs-parameter-strict
|
||||
-h, --help
|
||||
```
|
||||
|
||||
|
||||
@@ -290,8 +290,19 @@ export function registerCommands(program: Command) {
|
||||
'Mkdocs config file name',
|
||||
)
|
||||
.option(
|
||||
'--mkdocs-configs',
|
||||
'Additional parameters to pass to containerized mkdocs',
|
||||
'--mkdocs-parameter-clean',
|
||||
'Pass "--clean" parameter to mkdocs server running in containerized environment',
|
||||
false,
|
||||
)
|
||||
.option(
|
||||
'--mkdocs-parameter-dirty',
|
||||
'Pass "--dirty" parameter to mkdocs server running in containerized environment',
|
||||
false,
|
||||
)
|
||||
.option(
|
||||
'--mkdocs-parameter-strict',
|
||||
'Pass "--strict" parameter to mkdocs server running in containerized environment',
|
||||
false,
|
||||
)
|
||||
.hook('preAction', command => {
|
||||
if (
|
||||
|
||||
@@ -67,7 +67,6 @@ export default async function serve(opts: OptionValues) {
|
||||
? mkdocsDockerAddr
|
||||
: mkdocsLocalAddr;
|
||||
const mkdocsConfigFileName = opts.mkdocsConfigFileName;
|
||||
const mkdocsConfigs = opts.mkdocsConfig.split(' ');
|
||||
const siteName = opts.siteName;
|
||||
|
||||
const { path: mkdocsYmlPath, configIsTemporary } = await getMkdocsYml('./', {
|
||||
@@ -117,7 +116,9 @@ export default async function serve(opts: OptionValues) {
|
||||
stdoutLogFunc: mkdocsLogFunc,
|
||||
stderrLogFunc: mkdocsLogFunc,
|
||||
mkdocsConfigFileName: mkdocsYmlPath,
|
||||
mkdocsConfigs: mkdocsConfigs,
|
||||
mkdocsParameterClean: opts.mkdocsParameterClean,
|
||||
mkdocsParameterDirty: opts.mkdocsParameterDirty,
|
||||
mkdocsParameterStrict: opts.mkdocsParameterStrict,
|
||||
});
|
||||
|
||||
// Wait until mkdocs server has started so that Backstage starts with docs loaded
|
||||
|
||||
@@ -99,7 +99,10 @@ describe('runMkdocsServer', () => {
|
||||
});
|
||||
|
||||
it('should accept additinoal mkdocs CLI parameters', async () => {
|
||||
await runMkdocsServer({ mkdocsConfigs: ['--clean', '--strict'] });
|
||||
await runMkdocsServer({
|
||||
mkdocsParameterClean: true,
|
||||
mkdocsParameterStrict: true,
|
||||
});
|
||||
expect(run).toHaveBeenCalledWith(
|
||||
'docker',
|
||||
expect.arrayContaining([
|
||||
|
||||
@@ -26,7 +26,9 @@ export const runMkdocsServer = async (options: {
|
||||
stdoutLogFunc?: LogFunc;
|
||||
stderrLogFunc?: LogFunc;
|
||||
mkdocsConfigFileName?: string;
|
||||
mkdocsConfigs?: string[];
|
||||
mkdocsParameterClean?: boolean;
|
||||
mkdocsParameterDirty?: boolean;
|
||||
mkdocsParameterStrict?: boolean;
|
||||
}): Promise<ChildProcess> => {
|
||||
const port = options.port ?? '8000';
|
||||
const useDocker = options.useDocker ?? true;
|
||||
@@ -56,7 +58,9 @@ export const runMkdocsServer = async (options: {
|
||||
...(options.mkdocsConfigFileName
|
||||
? ['--config-file', options.mkdocsConfigFileName]
|
||||
: []),
|
||||
...(options.mkdocsConfigs ?? []),
|
||||
...(options.mkdocsParameterClean ? '--clean' : []),
|
||||
...(options.mkdocsParameterDirty ? '--dirty' : []),
|
||||
...(options.mkdocsParameterStrict ? '--strict' : []),
|
||||
],
|
||||
{
|
||||
stdoutLogFunc: options.stdoutLogFunc,
|
||||
@@ -74,7 +78,9 @@ export const runMkdocsServer = async (options: {
|
||||
...(options.mkdocsConfigFileName
|
||||
? ['--config-file', options.mkdocsConfigFileName]
|
||||
: []),
|
||||
...(options.mkdocsConfigs ?? []),
|
||||
...(options.mkdocsParameterClean ? '--clean' : []),
|
||||
...(options.mkdocsParameterDirty ? '--dirty' : []),
|
||||
...(options.mkdocsParameterStrict ? '--strict' : []),
|
||||
],
|
||||
{
|
||||
stdoutLogFunc: options.stdoutLogFunc,
|
||||
|
||||
Reference in New Issue
Block a user