mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-16 18:00:33 +03:00
fix: rename bandle command and add deprecate notice (#1935)
Co-authored-by: Roman Hotsiy <gotsijroman@gmail.com>
This commit is contained in:
parent
0c23f8d051
commit
eb096b69be
127
cli/index.ts
127
cli/index.ts
|
@ -59,7 +59,58 @@ export const mimeTypes = {
|
||||||
|
|
||||||
const BUNDLES_DIR = dirname(require.resolve('redoc'));
|
const BUNDLES_DIR = dirname(require.resolve('redoc'));
|
||||||
|
|
||||||
/* tslint:disable-next-line */
|
const builderForBuildCommand = yargs => {
|
||||||
|
yargs.positional('spec', {
|
||||||
|
describe: 'path or URL to your spec',
|
||||||
|
});
|
||||||
|
|
||||||
|
yargs.option('o', {
|
||||||
|
describe: 'Output file',
|
||||||
|
alias: 'output',
|
||||||
|
type: 'string',
|
||||||
|
default: 'redoc-static.html',
|
||||||
|
});
|
||||||
|
|
||||||
|
yargs.options('title', {
|
||||||
|
describe: 'Page Title',
|
||||||
|
type: 'string',
|
||||||
|
});
|
||||||
|
|
||||||
|
yargs.options('disableGoogleFont', {
|
||||||
|
describe: 'Disable Google Font',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
yargs.option('cdn', {
|
||||||
|
describe: 'Do not include ReDoc source code into html page, use link to CDN instead',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
yargs.demandOption('spec');
|
||||||
|
return yargs;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerForBuildCommand = async (argv: any) => {
|
||||||
|
const config = {
|
||||||
|
ssr: true,
|
||||||
|
output: argv.o as string,
|
||||||
|
cdn: argv.cdn as boolean,
|
||||||
|
title: argv.title as string,
|
||||||
|
disableGoogleFont: argv.disableGoogleFont as boolean,
|
||||||
|
templateFileName: argv.template as string,
|
||||||
|
templateOptions: argv.templateOptions || {},
|
||||||
|
redocOptions: getObjectOrJSON(argv.options),
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
await bundle(argv.spec, config);
|
||||||
|
} catch (e) {
|
||||||
|
handleError(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
YargsParser.command(
|
YargsParser.command(
|
||||||
'serve <spec>',
|
'serve <spec>',
|
||||||
'start the server',
|
'start the server',
|
||||||
|
@ -122,60 +173,32 @@ YargsParser.command(
|
||||||
handleError(e);
|
handleError(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
[
|
||||||
|
res => {
|
||||||
|
console.log(
|
||||||
|
`\n⚠️ This command is deprecated. Use "npx @redocly/openapi-cli preview-docs petstore.yaml"\n`,
|
||||||
|
);
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
.command(
|
||||||
|
'build <spec>',
|
||||||
|
'build definition into zero-dependency HTML-file',
|
||||||
|
builderForBuildCommand,
|
||||||
|
handlerForBuildCommand,
|
||||||
|
)
|
||||||
.command(
|
.command(
|
||||||
'bundle <spec>',
|
'bundle <spec>',
|
||||||
'bundle spec into zero-dependency HTML-file',
|
'bundle spec into zero-dependency HTML-file [deprecated]',
|
||||||
yargs => {
|
builderForBuildCommand,
|
||||||
yargs.positional('spec', {
|
handlerForBuildCommand,
|
||||||
describe: 'path or URL to your spec',
|
[
|
||||||
});
|
res => {
|
||||||
|
console.log(`\n⚠️ This command is deprecated. Use "build" command instead.\n`);
|
||||||
yargs.option('o', {
|
return res;
|
||||||
describe: 'Output file',
|
},
|
||||||
alias: 'output',
|
],
|
||||||
type: 'string',
|
|
||||||
default: 'redoc-static.html',
|
|
||||||
});
|
|
||||||
|
|
||||||
yargs.options('title', {
|
|
||||||
describe: 'Page Title',
|
|
||||||
type: 'string',
|
|
||||||
});
|
|
||||||
|
|
||||||
yargs.options('disableGoogleFont', {
|
|
||||||
describe: 'Disable Google Font',
|
|
||||||
type: 'boolean',
|
|
||||||
default: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
yargs.option('cdn', {
|
|
||||||
describe: 'Do not include ReDoc source code into html page, use link to CDN instead',
|
|
||||||
type: 'boolean',
|
|
||||||
default: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
yargs.demandOption('spec');
|
|
||||||
return yargs;
|
|
||||||
},
|
|
||||||
async (argv: any) => {
|
|
||||||
const config = {
|
|
||||||
ssr: true,
|
|
||||||
output: argv.o as string,
|
|
||||||
cdn: argv.cdn as boolean,
|
|
||||||
title: argv.title as string,
|
|
||||||
disableGoogleFont: argv.disableGoogleFont as boolean,
|
|
||||||
templateFileName: argv.template as string,
|
|
||||||
templateOptions: argv.templateOptions || {},
|
|
||||||
redocOptions: getObjectOrJSON(argv.options),
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
await bundle(argv.spec, config);
|
|
||||||
} catch (e) {
|
|
||||||
handleError(e);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
.demandCommand()
|
.demandCommand()
|
||||||
.options('t', {
|
.options('t', {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user