mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-03 03:40:23 +03:00
feat: add deprecation label to redoc-cli
This commit is contained in:
parent
1697d2ce78
commit
a51fd38e94
|
@ -84,7 +84,7 @@ Refer to the Redocly's documentation for more information on these products:
|
||||||
- [Simple integration with `create-react-app`](https://redoc.ly/docs/redoc/quickstart/react/)
|
- [Simple integration with `create-react-app`](https://redoc.ly/docs/redoc/quickstart/react/)
|
||||||
|
|
||||||
[Example repo](https://github.com/APIs-guru/create-react-app-redoc)
|
[Example repo](https://github.com/APIs-guru/create-react-app-redoc)
|
||||||
- [Command-line interface to bundle your docs into a **zero-dependency** HTML file](https://redoc.ly/docs/redoc/quickstart/cli/)
|
- [Command-line interface to bundle your docs into a **zero-dependency** HTML file](https://redocly.com/docs/cli/commands/build-docs/)
|
||||||
- Neat **interactive** documentation for nested objects <br>
|
- Neat **interactive** documentation for nested objects <br>
|
||||||

|

|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# redoc-cli
|
# redoc-cli
|
||||||
|
|
||||||
|
**DEPRECATED: this package is deprecated now, please use `@redocly/cli build-docs <api>` instead.**
|
||||||
|
|
||||||
**[ReDoc](https://github.com/Redocly/redoc)'s Command Line Interface**
|
**[ReDoc](https://github.com/Redocly/redoc)'s Command Line Interface**
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
62
cli/index.ts
62
cli/index.ts
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
/* tslint:disable:no-implicit-dependencies */
|
/* tslint:disable:no-implicit-dependencies */
|
||||||
import * as React from 'react';
|
import { createElement } from 'react';
|
||||||
import * as updateNotifier from 'update-notifier';
|
|
||||||
import { renderToString } from 'react-dom/server';
|
import { renderToString } from 'react-dom/server';
|
||||||
import { ServerStyleSheet } from 'styled-components';
|
import { ServerStyleSheet } from 'styled-components';
|
||||||
|
|
||||||
|
@ -10,6 +9,7 @@ import { createServer, IncomingMessage, ServerResponse } from 'http';
|
||||||
import { dirname, join, resolve, extname as getExtName } from 'path';
|
import { dirname, join, resolve, extname as getExtName } from 'path';
|
||||||
|
|
||||||
import * as zlib from 'zlib';
|
import * as zlib from 'zlib';
|
||||||
|
import * as boxen from 'boxen';
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { createStore, loadAndBundleSpec, Redoc } from 'redoc';
|
import { createStore, loadAndBundleSpec, Redoc } from 'redoc';
|
||||||
|
@ -112,7 +112,6 @@ const handlerForBuildCommand = async (argv: any) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
notifyUpdateCliVersion();
|
|
||||||
await bundle(argv.spec, config);
|
await bundle(argv.spec, config);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
handleError(e);
|
handleError(e);
|
||||||
|
@ -121,7 +120,7 @@ const handlerForBuildCommand = async (argv: any) => {
|
||||||
|
|
||||||
YargsParser.command(
|
YargsParser.command(
|
||||||
'serve <spec>',
|
'serve <spec>',
|
||||||
'start the server',
|
'start the server [deprecated]',
|
||||||
yargs => {
|
yargs => {
|
||||||
yargs.positional('spec', {
|
yargs.positional('spec', {
|
||||||
describe: 'path or URL to your spec',
|
describe: 'path or URL to your spec',
|
||||||
|
@ -176,7 +175,6 @@ YargsParser.command(
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
notifyUpdateCliVersion();
|
|
||||||
await serve(argv.host as string, argv.port as number, argv.spec as string, config);
|
await serve(argv.host as string, argv.port as number, argv.spec as string, config);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
handleError(e);
|
handleError(e);
|
||||||
|
@ -184,30 +182,37 @@ YargsParser.command(
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
res => {
|
res => {
|
||||||
console.log(
|
console.log(`
|
||||||
`\n⚠️ This command is deprecated. Use "npx @redocly/cli preview-docs petstore.yaml"\n`,
|
${boxen(
|
||||||
);
|
'This package is deprecated now.\n\nPlease use `@redocly/cli preview-docs <api>` instead.',
|
||||||
|
{
|
||||||
|
title: 'DEPRECATED',
|
||||||
|
titleAlignment: 'center',
|
||||||
|
padding: 1,
|
||||||
|
margin: 1,
|
||||||
|
borderColor: 'red',
|
||||||
|
},
|
||||||
|
)}`);
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
.command(
|
.command(
|
||||||
'build <spec>',
|
'build <spec>',
|
||||||
'build definition into zero-dependency HTML-file',
|
'build definition into zero-dependency HTML-file [deprecated]',
|
||||||
builderForBuildCommand,
|
builderForBuildCommand,
|
||||||
handlerForBuildCommand,
|
handlerForBuildCommand,
|
||||||
|
[notifyDeprecation],
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
.command(
|
.command(
|
||||||
'bundle <spec>',
|
'bundle <spec>',
|
||||||
'bundle spec into zero-dependency HTML-file [deprecated]',
|
'bundle spec into zero-dependency HTML-file [deprecated]',
|
||||||
builderForBuildCommand,
|
builderForBuildCommand,
|
||||||
handlerForBuildCommand,
|
handlerForBuildCommand,
|
||||||
[
|
[notifyDeprecation],
|
||||||
res => {
|
true,
|
||||||
console.log(`\n⚠️ This command is deprecated. Use "build" command instead.\n`);
|
|
||||||
return res;
|
|
||||||
},
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
.demandCommand()
|
.demandCommand()
|
||||||
.options('t', {
|
.options('t', {
|
||||||
|
@ -344,7 +349,7 @@ async function getPageHTML(
|
||||||
const store = await createStore(spec, specUrl, redocOptions);
|
const store = await createStore(spec, specUrl, redocOptions);
|
||||||
const sheet = new ServerStyleSheet();
|
const sheet = new ServerStyleSheet();
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
html = renderToString(sheet.collectStyles(React.createElement(Redoc, { store })));
|
html = renderToString(sheet.collectStyles(createElement(Redoc, { store })));
|
||||||
css = sheet.getStyleTags();
|
css = sheet.getStyleTags();
|
||||||
state = await store.toJS();
|
state = await store.toJS();
|
||||||
|
|
||||||
|
@ -472,15 +477,18 @@ function getObjectOrJSON(options) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function notifyUpdateCliVersion() {
|
function notifyDeprecation(res: YargsParser.Arguments): YargsParser.Arguments {
|
||||||
const pkg = require('./package.json');
|
console.log(
|
||||||
const notifier = updateNotifier({
|
boxen(
|
||||||
pkg,
|
'This package is deprecated now.\n\nPlease use `@redocly/cli build-docs <api>` instead.',
|
||||||
updateCheckInterval: 0,
|
{
|
||||||
shouldNotifyInNpmScript: true,
|
title: 'DEPRECATED',
|
||||||
});
|
titleAlignment: 'center',
|
||||||
notifier.notify({
|
padding: 1,
|
||||||
message:
|
margin: 1,
|
||||||
'Run `{updateCommand}` to update.\nChangelog: https://github.com/Redocly/redoc/releases/tag/{latestVersion}',
|
borderColor: 'red',
|
||||||
});
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
1266
cli/npm-shrinkwrap.json
generated
1266
cli/npm-shrinkwrap.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -11,6 +11,7 @@
|
||||||
"node": ">=12.0.0"
|
"node": ">=12.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"boxen": "5.1.2",
|
||||||
"chokidar": "^3.5.1",
|
"chokidar": "^3.5.1",
|
||||||
"handlebars": "^4.7.7",
|
"handlebars": "^4.7.7",
|
||||||
"isarray": "^2.0.5",
|
"isarray": "^2.0.5",
|
||||||
|
@ -21,7 +22,6 @@
|
||||||
"react-dom": "^17.0.1",
|
"react-dom": "^17.0.1",
|
||||||
"redoc": "2.0.0-rc.77",
|
"redoc": "2.0.0-rc.77",
|
||||||
"styled-components": "^5.3.0",
|
"styled-components": "^5.3.0",
|
||||||
"update-notifier": "^5.0.1",
|
|
||||||
"yargs": "^17.3.1"
|
"yargs": "^17.3.1"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user