mirror of
https://github.com/Redocly/redoc.git
synced 2025-03-04 01:45:47 +03:00
chore: fix cli lint issues
This commit is contained in:
parent
50184739c7
commit
3ee4210e6f
33
cli/index.ts
33
cli/index.ts
|
@ -1,20 +1,23 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
/* tslint:disable:no-implicit-dependencies */
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { renderToString } from 'react-dom/server';
|
import { renderToString } from 'react-dom/server';
|
||||||
import { ServerStyleSheet } from 'styled-components';
|
import { ServerStyleSheet } from 'styled-components';
|
||||||
import { createServer, ServerResponse, ServerRequest } from 'http';
|
|
||||||
import * as zlib from 'zlib';
|
|
||||||
import { join, dirname } from 'path';
|
|
||||||
import { compile } from 'handlebars';
|
import { compile } from 'handlebars';
|
||||||
|
import { createServer, ServerRequest, ServerResponse } from 'http';
|
||||||
|
import { dirname, join } from 'path';
|
||||||
|
|
||||||
|
import * as zlib from 'zlib';
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { Redoc, loadAndBundleSpec, createStore } from 'redoc';
|
import { createStore, loadAndBundleSpec, Redoc } from 'redoc';
|
||||||
|
|
||||||
import { createReadStream, writeFileSync, ReadStream, readFileSync, watch, existsSync } from 'fs';
|
import { createReadStream, existsSync, readFileSync, ReadStream, watch, writeFileSync } from 'fs';
|
||||||
|
|
||||||
import * as yargs from 'yargs';
|
import * as YargsParser from 'yargs';
|
||||||
|
|
||||||
type Options = {
|
interface Options {
|
||||||
ssr?: boolean;
|
ssr?: boolean;
|
||||||
watch?: boolean;
|
watch?: boolean;
|
||||||
cdn?: boolean;
|
cdn?: boolean;
|
||||||
|
@ -22,12 +25,12 @@ type Options = {
|
||||||
title?: string;
|
title?: string;
|
||||||
templateFileName?: string;
|
templateFileName?: string;
|
||||||
redocOptions?: any;
|
redocOptions?: any;
|
||||||
};
|
}
|
||||||
|
|
||||||
const BUNDLES_DIR = dirname(require.resolve('redoc'));
|
const BUNDLES_DIR = dirname(require.resolve('redoc'));
|
||||||
|
|
||||||
yargs
|
/* tslint:disable-next-line */
|
||||||
.command(
|
YargsParser.command(
|
||||||
'serve [spec]',
|
'serve [spec]',
|
||||||
'start the server',
|
'start the server',
|
||||||
yargs => {
|
yargs => {
|
||||||
|
@ -67,7 +70,7 @@ yargs
|
||||||
console.log(e.stack);
|
console.log(e.stack);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.command(
|
.command(
|
||||||
'bundle [spec]',
|
'bundle [spec]',
|
||||||
'bundle spec into zero-dependency HTML-file',
|
'bundle spec into zero-dependency HTML-file',
|
||||||
|
@ -196,7 +199,9 @@ async function getPageHTML(
|
||||||
pathToSpec: string,
|
pathToSpec: string,
|
||||||
{ ssr, cdn, title, templateFileName, redocOptions = {} }: Options,
|
{ ssr, cdn, title, templateFileName, redocOptions = {} }: Options,
|
||||||
) {
|
) {
|
||||||
let html, css, state;
|
let html;
|
||||||
|
let css;
|
||||||
|
let state;
|
||||||
let redocStandaloneSrc;
|
let redocStandaloneSrc;
|
||||||
if (ssr) {
|
if (ssr) {
|
||||||
console.log('Prerendering docs');
|
console.log('Prerendering docs');
|
||||||
|
@ -234,7 +239,7 @@ async function getPageHTML(
|
||||||
? '<script src="https://unpkg.com/redoc@next/bundles/redoc.standalone.js"></script>'
|
? '<script src="https://unpkg.com/redoc@next/bundles/redoc.standalone.js"></script>'
|
||||||
: `<script>${redocStandaloneSrc}</script>`) + css
|
: `<script>${redocStandaloneSrc}</script>`) + css
|
||||||
: '<script src="redoc.standalone.js"></script>',
|
: '<script src="redoc.standalone.js"></script>',
|
||||||
title: title,
|
title,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +279,7 @@ function respondWithGzip(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function debounce(callback: Function, time: number) {
|
function debounce(callback: (...args) => void, time: number) {
|
||||||
let interval;
|
let interval;
|
||||||
return (...args) => {
|
return (...args) => {
|
||||||
clearTimeout(interval);
|
clearTimeout(interval);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user