@redocly/cli 1.0.0-beta.130 → 1.0.0-beta.131

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,6 @@ jest.mock('fs');
19
19
  jest.mock('../../utils');
20
20
  const config = {
21
21
  output: '',
22
- cdn: false,
23
22
  title: 'Test',
24
23
  disableGoogleFont: false,
25
24
  templateFileName: '',
@@ -46,7 +45,6 @@ describe('build-docs', () => {
46
45
  const processExitMock = jest.spyOn(process, 'exit').mockImplementation();
47
46
  yield build_docs_1.handlerBuildCommand({
48
47
  o: '',
49
- cdn: false,
50
48
  title: 'test',
51
49
  disableGoogleFont: false,
52
50
  template: '',
@@ -25,7 +25,6 @@ const handlerBuildCommand = (argv, configFromFile) => __awaiter(void 0, void 0,
25
25
  const { path: pathToApi } = apis[0];
26
26
  const options = {
27
27
  output: argv.o,
28
- cdn: argv.cdn,
29
28
  title: argv.title,
30
29
  disableGoogleFont: argv.disableGoogleFont,
31
30
  templateFileName: argv.template,
@@ -1,6 +1,5 @@
1
1
  export declare type BuildDocsOptions = {
2
2
  watch?: boolean;
3
- cdn?: boolean;
4
3
  output?: string;
5
4
  title?: string;
6
5
  disableGoogleFont?: boolean;
@@ -13,7 +12,6 @@ export declare type BuildDocsOptions = {
13
12
  export declare type BuildDocsArgv = {
14
13
  api: string;
15
14
  o: string;
16
- cdn: boolean;
17
15
  title?: string;
18
16
  disableGoogleFont?: boolean;
19
17
  template?: string;
@@ -1,7 +1,7 @@
1
1
  import { Config } from '@redocly/openapi-core';
2
2
  import type { BuildDocsOptions } from './types';
3
3
  export declare function getObjectOrJSON(openapiOptions: string | Record<string, unknown>, config: Config): JSON | Record<string, unknown> | Config;
4
- export declare function getPageHTML(api: any, pathToApi: string, { cdn, title, disableGoogleFont, templateFileName, templateOptions, redocOptions, redocCurrentVersion, }: BuildDocsOptions): Promise<string>;
4
+ export declare function getPageHTML(api: any, pathToApi: string, { title, disableGoogleFont, templateFileName, templateOptions, redocOptions, redocCurrentVersion, }: BuildDocsOptions): Promise<string>;
5
5
  export declare function sanitizeJSONString(str: string): string;
6
6
  export declare function escapeClosingScriptTag(str: string): string;
7
7
  export declare function escapeUnicode(str: string): string;
@@ -49,7 +49,7 @@ function getObjectOrJSON(openapiOptions, config) {
49
49
  return {};
50
50
  }
51
51
  exports.getObjectOrJSON = getObjectOrJSON;
52
- function getPageHTML(api, pathToApi, { cdn, title, disableGoogleFont, templateFileName, templateOptions, redocOptions = {}, redocCurrentVersion, }) {
52
+ function getPageHTML(api, pathToApi, { title, disableGoogleFont, templateFileName, templateOptions, redocOptions = {}, redocCurrentVersion, }) {
53
53
  return __awaiter(this, void 0, void 0, function* () {
54
54
  process.stderr.write('Prerendering docs');
55
55
  const apiUrl = redocOptions.specUrl || (openapi_core_1.isAbsoluteUrl(pathToApi) ? pathToApi : undefined);
@@ -74,9 +74,7 @@ function getPageHTML(api, pathToApi, { cdn, title, disableGoogleFont, templateFi
74
74
  Redoc.${'hydrate(__redoc_state, container)'};
75
75
 
76
76
  </script>`,
77
- redocHead: (cdn
78
- ? '<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"></script>'
79
- : `<script src="https://cdn.redoc.ly/redoc/v${redocCurrentVersion}/bundles/redoc.standalone.js"></script>`) +
77
+ redocHead: `<script src="https://cdn.redoc.ly/redoc/v${redocCurrentVersion}/bundles/redoc.standalone.js"></script>` +
80
78
  css,
81
79
  title: title || api.info.title || 'ReDoc documentation',
82
80
  disableGoogleFont,
@@ -1,2 +1,2 @@
1
- declare const _default: (url: string, options?: {}) => Promise<import("node-fetch").Response>;
1
+ declare const _default: (url: string, options?: {}) => Promise<import("node-fetch").Response | undefined>;
2
2
  export default _default;
@@ -12,14 +12,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const node_fetch_1 = require("node-fetch");
13
13
  const TIMEOUT = 3000;
14
14
  exports.default = (url, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
15
- if (!global.AbortController) {
16
- return node_fetch_1.default(url, options);
15
+ try {
16
+ if (!global.AbortController) {
17
+ return node_fetch_1.default(url, options);
18
+ }
19
+ const controller = new AbortController();
20
+ const timeout = setTimeout(() => {
21
+ controller.abort();
22
+ }, TIMEOUT);
23
+ const res = yield node_fetch_1.default(url, Object.assign({ signal: controller.signal }, options));
24
+ clearTimeout(timeout);
25
+ return res;
26
+ }
27
+ catch (e) {
28
+ return;
17
29
  }
18
- const controller = new AbortController();
19
- const timeout = setTimeout(() => {
20
- controller.abort();
21
- }, TIMEOUT);
22
- const res = yield node_fetch_1.default(url, Object.assign({ signal: controller.signal }, options));
23
- clearTimeout(timeout);
24
- return res;
25
30
  });
package/lib/index.js CHANGED
@@ -397,11 +397,6 @@ yargs
397
397
  type: 'boolean',
398
398
  default: false,
399
399
  },
400
- cdn: {
401
- describe: 'Do not include Redoc source code into html page, use link to CDN instead',
402
- type: 'boolean',
403
- default: false,
404
- },
405
400
  t: {
406
401
  alias: 'template',
407
402
  describe: 'Path to handlebars page template, see https://git.io/vh8fP for the example',
@@ -42,6 +42,8 @@ const isNewVersionAvailable = (current, latest) => semver_1.compare(current, lat
42
42
  const getLatestVersion = (packageName) => __awaiter(void 0, void 0, void 0, function* () {
43
43
  const latestUrl = `http://registry.npmjs.org/${packageName}/latest`;
44
44
  const response = yield fetch_with_timeout_1.default(latestUrl);
45
+ if (!response)
46
+ return;
45
47
  const info = yield response.json();
46
48
  return info.version;
47
49
  });
@@ -51,8 +53,10 @@ const cacheLatestVersion = () => {
51
53
  }
52
54
  getLatestVersion(exports.name)
53
55
  .then((version) => {
54
- const lastCheckFile = path_1.join(os_1.tmpdir(), VERSION_CACHE_FILE);
55
- fs_1.writeFileSync(lastCheckFile, version);
56
+ if (version) {
57
+ const lastCheckFile = path_1.join(os_1.tmpdir(), VERSION_CACHE_FILE);
58
+ fs_1.writeFileSync(lastCheckFile, version);
59
+ }
56
60
  })
57
61
  .catch(() => { });
58
62
  };
package/lib/utils.js CHANGED
@@ -417,7 +417,7 @@ function sendTelemetry(argv, exit_code, has_config) {
417
417
  const { _: [command], $0: _ } = argv, args = __rest(argv, ["_", "$0"]);
418
418
  const event_time = new Date().toISOString();
419
419
  const redoclyClient = new openapi_core_1.RedoclyClient();
420
- const logged_in = yield redoclyClient.isAuthorizedWithRedoclyByRegion();
420
+ const logged_in = redoclyClient.hasTokens();
421
421
  const data = {
422
422
  event: 'cli_command',
423
423
  event_time,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/cli",
3
- "version": "1.0.0-beta.130",
3
+ "version": "1.0.0-beta.131",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -14,6 +14,7 @@
14
14
  "scripts": {
15
15
  "compile": "tsc",
16
16
  "copy-assets": "cp src/commands/preview-docs/preview-server/default.hbs lib/commands/preview-docs/preview-server/default.hbs && cp src/commands/preview-docs/preview-server/hot.js lib/commands/preview-docs/preview-server/hot.js && cp src/commands/preview-docs/preview-server/oauth2-redirect.html lib/commands/preview-docs/preview-server/oauth2-redirect.html && cp src/commands/build-docs/template.hbs lib/commands/build-docs/template.hbs",
17
+ "prepack": "npm run copy-assets",
17
18
  "prepublishOnly": "npm run copy-assets"
18
19
  },
19
20
  "repository": {
@@ -33,7 +34,7 @@
33
34
  "Roman Hotsiy <roman@redoc.ly> (https://redoc.ly/)"
34
35
  ],
35
36
  "dependencies": {
36
- "@redocly/openapi-core": "1.0.0-beta.130",
37
+ "@redocly/openapi-core": "1.0.0-beta.131",
37
38
  "assert-node-version": "^1.0.3",
38
39
  "chokidar": "^3.5.1",
39
40
  "colorette": "^1.2.0",
@@ -44,13 +45,11 @@
44
45
  "redoc": "~2.0.0",
45
46
  "semver": "^7.5.2",
46
47
  "simple-websocket": "^9.0.0",
47
- "yargs": "17.0.1"
48
- },
49
- "peerDependencies": {
48
+ "yargs": "17.0.1",
50
49
  "mobx": "^6.0.4",
51
- "react": "^16.8.4 || ^17.0.0",
52
- "react-dom": "^16.8.4 || ^17.0.0",
53
- "styled-components": "^4.1.1 || ^5.1.1"
50
+ "react": "^17.0.0",
51
+ "react-dom": "^17.0.0",
52
+ "styled-components": "^5.1.1"
54
53
  },
55
54
  "devDependencies": {
56
55
  "@types/configstore": "^5.0.1",