@redocly/cli 1.0.0-beta.104 → 1.0.0-beta.107

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.
Files changed (63) hide show
  1. package/bin/cli.js +1 -1
  2. package/lib/__mocks__/@redocly/openapi-core.d.ts +2 -1
  3. package/lib/__mocks__/@redocly/openapi-core.js +2 -1
  4. package/lib/__mocks__/perf_hooks.js +1 -1
  5. package/lib/__mocks__/utils.d.ts +1 -1
  6. package/lib/__mocks__/utils.js +2 -2
  7. package/lib/__tests__/commands/bundle.test.js +52 -17
  8. package/lib/__tests__/commands/join.test.js +4 -4
  9. package/lib/__tests__/commands/lint.test.js +14 -8
  10. package/lib/__tests__/commands/push-region.test.js +2 -2
  11. package/lib/__tests__/commands/push.test.js +18 -18
  12. package/lib/__tests__/fixtures/config.d.ts +1 -1
  13. package/lib/__tests__/fixtures/config.js +1 -1
  14. package/lib/commands/bundle.d.ts +4 -12
  15. package/lib/commands/bundle.js +12 -11
  16. package/lib/commands/join.d.ts +1 -1
  17. package/lib/commands/join.js +105 -56
  18. package/lib/commands/lint.d.ts +3 -9
  19. package/lib/commands/lint.js +14 -11
  20. package/lib/commands/preview-docs/index.d.ts +3 -5
  21. package/lib/commands/preview-docs/index.js +14 -14
  22. package/lib/commands/push.d.ts +6 -6
  23. package/lib/commands/push.js +26 -26
  24. package/lib/commands/split/__tests__/index.test.js +8 -8
  25. package/lib/commands/split/index.d.ts +1 -1
  26. package/lib/commands/split/index.js +12 -11
  27. package/lib/commands/split/types.d.ts +2 -2
  28. package/lib/commands/split/types.js +2 -2
  29. package/lib/commands/stats.d.ts +1 -1
  30. package/lib/commands/stats.js +9 -7
  31. package/lib/index.js +12 -16
  32. package/lib/js-utils.js +2 -2
  33. package/lib/types.d.ts +13 -1
  34. package/lib/utils.d.ts +4 -4
  35. package/lib/utils.js +15 -17
  36. package/package.json +2 -2
  37. package/src/__mocks__/@redocly/openapi-core.ts +1 -0
  38. package/src/__mocks__/perf_hooks.ts +2 -2
  39. package/src/__mocks__/utils.ts +3 -1
  40. package/src/__tests__/commands/bundle.test.ts +71 -22
  41. package/src/__tests__/commands/join.test.ts +8 -8
  42. package/src/__tests__/commands/lint.test.ts +24 -11
  43. package/src/__tests__/commands/push-region.test.ts +2 -2
  44. package/src/__tests__/commands/push.test.ts +19 -24
  45. package/src/__tests__/fixtures/config.ts +1 -1
  46. package/src/__tests__/utils.test.ts +5 -8
  47. package/src/commands/bundle.ts +28 -40
  48. package/src/commands/join.ts +209 -119
  49. package/src/commands/lint.ts +30 -30
  50. package/src/commands/login.ts +2 -2
  51. package/src/commands/preview-docs/index.ts +33 -40
  52. package/src/commands/preview-docs/preview-server/preview-server.ts +6 -6
  53. package/src/commands/preview-docs/preview-server/server.ts +1 -1
  54. package/src/commands/push.ts +44 -53
  55. package/src/commands/split/__tests__/index.test.ts +47 -30
  56. package/src/commands/split/index.ts +84 -46
  57. package/src/commands/split/types.ts +19 -7
  58. package/src/commands/stats.ts +27 -24
  59. package/src/index.ts +16 -20
  60. package/src/js-utils.ts +2 -2
  61. package/src/types.ts +14 -1
  62. package/src/utils.ts +53 -53
  63. package/tsconfig.tsbuildinfo +1 -1
package/bin/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- require("../lib/index");
3
+ require('../lib/index');
@@ -23,7 +23,7 @@ export declare const RedoclyClient: jest.Mock<{
23
23
  }, []>;
24
24
  export declare const loadConfig: jest.Mock<{
25
25
  configFile: null;
26
- lint: {
26
+ styleguide: {
27
27
  addIgnore: jest.Mock<any, any>;
28
28
  skipRules: jest.Mock<any, any>;
29
29
  skipPreprocessors: jest.Mock<any, any>;
@@ -46,3 +46,4 @@ export declare const getTotals: jest.Mock<{
46
46
  export declare const formatProblems: jest.Mock<any, any>;
47
47
  export declare const slash: jest.Mock<any, any>;
48
48
  export declare const findConfig: jest.Mock<any, any>;
49
+ export declare const doesYamlFileExist: jest.Mock<any, any>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findConfig = exports.slash = exports.formatProblems = exports.getTotals = exports.bundle = exports.lint = exports.getMergedConfig = exports.loadConfig = exports.RedoclyClient = exports.__redoclyClient = void 0;
3
+ exports.doesYamlFileExist = exports.findConfig = exports.slash = exports.formatProblems = exports.getTotals = exports.bundle = exports.lint = exports.getMergedConfig = exports.loadConfig = exports.RedoclyClient = exports.__redoclyClient = void 0;
4
4
  const config_1 = require("./../../__tests__/fixtures/config");
5
5
  exports.__redoclyClient = {
6
6
  isAuthorizedWithRedocly: jest.fn().mockResolvedValue(true),
@@ -25,3 +25,4 @@ exports.getTotals = jest.fn(() => ({ errors: 0 }));
25
25
  exports.formatProblems = jest.fn();
26
26
  exports.slash = jest.fn();
27
27
  exports.findConfig = jest.fn();
28
+ exports.doesYamlFileExist = jest.fn();
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.performance = void 0;
4
4
  exports.performance = {
5
- now: jest.fn()
5
+ now: jest.fn(),
6
6
  };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="jest" />
2
- export declare const getFallbackEntryPointsOrExit: jest.Mock<any, [entrypoints: any]>;
2
+ export declare const getFallbackApisOrExit: jest.Mock<any, [entrypoints: any]>;
3
3
  export declare const dumpBundle: jest.Mock<string, []>;
4
4
  export declare const slash: jest.Mock<any, any>;
5
5
  export declare const pluralize: jest.Mock<any, any>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exitWithError = exports.handleError = exports.getOutputFileName = exports.printLintTotals = exports.printUnusedWarnings = exports.printExecutionTime = exports.getExecutionTime = exports.pluralize = exports.slash = exports.dumpBundle = exports.getFallbackEntryPointsOrExit = void 0;
4
- exports.getFallbackEntryPointsOrExit = jest.fn((entrypoints) => entrypoints.map(() => ({ path: '' })));
3
+ exports.exitWithError = exports.handleError = exports.getOutputFileName = exports.printLintTotals = exports.printUnusedWarnings = exports.printExecutionTime = exports.getExecutionTime = exports.pluralize = exports.slash = exports.dumpBundle = exports.getFallbackApisOrExit = void 0;
4
+ exports.getFallbackApisOrExit = jest.fn((entrypoints) => entrypoints.map((path) => ({ path })));
5
5
  exports.dumpBundle = jest.fn(() => '');
6
6
  exports.slash = jest.fn();
7
7
  exports.pluralize = jest.fn();
@@ -11,9 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const openapi_core_1 = require("@redocly/openapi-core");
13
13
  const bundle_1 = require("../../commands/bundle");
14
+ const utils_1 = require("../../utils");
14
15
  jest.mock('@redocly/openapi-core');
15
16
  jest.mock('../../utils');
16
- openapi_core_1.getMergedConfig.mockImplementation(config => config);
17
+ openapi_core_1.getMergedConfig.mockImplementation((config) => config);
17
18
  describe('bundle', () => {
18
19
  let processExitMock;
19
20
  let exitCb;
@@ -28,22 +29,22 @@ describe('bundle', () => {
28
29
  afterEach(() => {
29
30
  openapi_core_1.lint.mockClear();
30
31
  openapi_core_1.bundle.mockClear();
31
- openapi_core_1.getTotals.mockClear();
32
+ openapi_core_1.getTotals.mockReset();
32
33
  });
33
34
  it('bundles definitions w/o linting', () => __awaiter(void 0, void 0, void 0, function* () {
34
- const entrypoints = ['foo.yaml', 'bar.yaml'];
35
+ const apis = ['foo.yaml', 'bar.yaml'];
35
36
  yield bundle_1.handleBundle({
36
- entrypoints,
37
+ apis,
37
38
  ext: 'yaml',
38
39
  format: 'codeframe',
39
40
  }, '1.0.0');
40
41
  expect(openapi_core_1.lint).toBeCalledTimes(0);
41
- expect(openapi_core_1.bundle).toBeCalledTimes(entrypoints.length);
42
+ expect(openapi_core_1.bundle).toBeCalledTimes(apis.length);
42
43
  }));
43
44
  it('exits with code 0 when bundles definitions', () => __awaiter(void 0, void 0, void 0, function* () {
44
- const entrypoints = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
45
+ const apis = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
45
46
  yield bundle_1.handleBundle({
46
- entrypoints,
47
+ apis,
47
48
  ext: 'yaml',
48
49
  format: 'codeframe',
49
50
  }, '1.0.0');
@@ -51,20 +52,25 @@ describe('bundle', () => {
51
52
  expect(processExitMock).toHaveBeenCalledWith(0);
52
53
  }));
53
54
  it('bundles definitions w/ linting', () => __awaiter(void 0, void 0, void 0, function* () {
54
- const entrypoints = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
55
+ const apis = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
56
+ openapi_core_1.getTotals.mockReturnValue({
57
+ errors: 0,
58
+ warnings: 0,
59
+ ignored: 0,
60
+ });
55
61
  yield bundle_1.handleBundle({
56
- entrypoints,
62
+ apis,
57
63
  ext: 'yaml',
58
64
  format: 'codeframe',
59
65
  lint: true,
60
66
  }, '1.0.0');
61
- expect(openapi_core_1.lint).toBeCalledTimes(entrypoints.length);
62
- expect(openapi_core_1.bundle).toBeCalledTimes(entrypoints.length);
67
+ expect(openapi_core_1.lint).toBeCalledTimes(apis.length);
68
+ expect(openapi_core_1.bundle).toBeCalledTimes(apis.length);
63
69
  }));
64
70
  it('exits with code 0 when bundles definitions w/linting w/o errors', () => __awaiter(void 0, void 0, void 0, function* () {
65
- const entrypoints = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
71
+ const apis = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
66
72
  yield bundle_1.handleBundle({
67
- entrypoints,
73
+ apis,
68
74
  ext: 'yaml',
69
75
  format: 'codeframe',
70
76
  lint: true,
@@ -73,20 +79,49 @@ describe('bundle', () => {
73
79
  expect(processExitMock).toHaveBeenCalledWith(0);
74
80
  }));
75
81
  it('exits with code 1 when bundles definitions w/linting w/errors', () => __awaiter(void 0, void 0, void 0, function* () {
76
- const entrypoints = ['foo.yaml'];
82
+ const apis = ['foo.yaml'];
77
83
  openapi_core_1.getTotals.mockReturnValue({
78
84
  errors: 1,
79
85
  warnings: 0,
80
- ignored: 0
86
+ ignored: 0,
81
87
  });
82
88
  yield bundle_1.handleBundle({
83
- entrypoints,
89
+ apis,
84
90
  ext: 'yaml',
85
91
  format: 'codeframe',
86
92
  lint: true,
87
93
  }, '1.0.0');
88
- expect(openapi_core_1.lint).toBeCalledTimes(entrypoints.length);
94
+ expect(openapi_core_1.lint).toBeCalledTimes(apis.length);
89
95
  exitCb === null || exitCb === void 0 ? void 0 : exitCb();
90
96
  expect(processExitMock).toHaveBeenCalledWith(1);
91
97
  }));
98
+ it('handleError is called when bundles an invalid definition', () => __awaiter(void 0, void 0, void 0, function* () {
99
+ const apis = ['invalid.json'];
100
+ openapi_core_1.bundle.mockImplementationOnce(() => {
101
+ throw new Error('Invalid definition');
102
+ });
103
+ yield bundle_1.handleBundle({
104
+ apis,
105
+ ext: 'json',
106
+ format: 'codeframe',
107
+ lint: false,
108
+ }, '1.0.0');
109
+ expect(utils_1.handleError).toHaveBeenCalledTimes(1);
110
+ expect(utils_1.handleError).toHaveBeenCalledWith(new Error('Invalid definition'), 'invalid.json');
111
+ }));
112
+ it("handleError isn't called when bundles a valid definition", () => __awaiter(void 0, void 0, void 0, function* () {
113
+ const apis = ['foo.yaml'];
114
+ openapi_core_1.getTotals.mockReturnValue({
115
+ errors: 0,
116
+ warnings: 0,
117
+ ignored: 0,
118
+ });
119
+ yield bundle_1.handleBundle({
120
+ apis,
121
+ ext: 'yaml',
122
+ format: 'codeframe',
123
+ lint: false,
124
+ }, '1.0.0');
125
+ expect(utils_1.handleError).toHaveBeenCalledTimes(0);
126
+ }));
92
127
  });
@@ -18,12 +18,12 @@ describe('handleJoin fails', () => {
18
18
  const colloreteYellowMock = colorette_1.yellow;
19
19
  colloreteYellowMock.mockImplementation((string) => string);
20
20
  it('should call exitWithError because only one entrypoint', () => __awaiter(void 0, void 0, void 0, function* () {
21
- yield join_1.handleJoin({ entrypoints: ['first.yaml'] }, 'cli-version');
22
- expect(utils_1.exitWithError).toHaveBeenCalledWith(`At least 2 entrypoints should be provided. \n\n`);
21
+ yield join_1.handleJoin({ apis: ['first.yaml'] }, 'cli-version');
22
+ expect(utils_1.exitWithError).toHaveBeenCalledWith(`At least 2 apis should be provided. \n\n`);
23
23
  }));
24
24
  it('should call exitWithError because passed all 3 options for tags', () => __awaiter(void 0, void 0, void 0, function* () {
25
25
  yield join_1.handleJoin({
26
- entrypoints: ['first.yaml', 'second.yaml'],
26
+ apis: ['first.yaml', 'second.yaml'],
27
27
  'prefix-tags-with-info-prop': 'something',
28
28
  'without-x-tag-groups': true,
29
29
  'prefix-tags-with-filename': true,
@@ -32,7 +32,7 @@ describe('handleJoin fails', () => {
32
32
  }));
33
33
  it('should call exitWithError because passed all 2 options for tags', () => __awaiter(void 0, void 0, void 0, function* () {
34
34
  yield join_1.handleJoin({
35
- entrypoints: ['first.yaml', 'second.yaml'],
35
+ apis: ['first.yaml', 'second.yaml'],
36
36
  'without-x-tag-groups': true,
37
37
  'prefix-tags-with-filename': true,
38
38
  }, 'cli-version');
@@ -18,7 +18,7 @@ jest.mock('@redocly/openapi-core');
18
18
  jest.mock('../../utils');
19
19
  jest.mock('perf_hooks');
20
20
  const argvMock = {
21
- entrypoints: ['openapi.yaml'],
21
+ apis: ['openapi.yaml'],
22
22
  'lint-config': 'off',
23
23
  format: 'codeframe',
24
24
  };
@@ -36,19 +36,25 @@ describe('handleLint', () => {
36
36
  return process.on(_e, cb);
37
37
  });
38
38
  getMergedConfigMock.mockReturnValue(config_1.ConfigFixture);
39
+ openapi_core_1.doesYamlFileExist.mockImplementation((path) => path === 'redocly.yaml');
39
40
  });
40
41
  afterEach(() => {
41
42
  getMergedConfigMock.mockReset();
42
43
  });
43
44
  describe('loadConfig and getEnrtypoints stage', () => {
44
- it('shoul call loadConfig and getFallbackEntryPointsOrExit', () => __awaiter(void 0, void 0, void 0, function* () {
45
+ it('should fail if config file does not exist', () => __awaiter(void 0, void 0, void 0, function* () {
46
+ yield lint_1.handleLint(Object.assign(Object.assign({}, argvMock), { config: 'config.yaml' }), versionMock);
47
+ expect(utils_1.exitWithError).toHaveBeenCalledWith('Please, provide valid path to the configuration file');
48
+ expect(openapi_core_1.loadConfig).toHaveBeenCalledTimes(0);
49
+ }));
50
+ it('should call loadConfig and getFallbackApisOrExit', () => __awaiter(void 0, void 0, void 0, function* () {
45
51
  yield lint_1.handleLint(argvMock, versionMock);
46
52
  expect(openapi_core_1.loadConfig).toHaveBeenCalledWith(undefined, undefined, undefined);
47
- expect(utils_1.getFallbackEntryPointsOrExit).toHaveBeenCalled();
53
+ expect(utils_1.getFallbackApisOrExit).toHaveBeenCalled();
48
54
  }));
49
55
  it('should call loadConfig with args if such exist', () => __awaiter(void 0, void 0, void 0, function* () {
50
- yield lint_1.handleLint(Object.assign(Object.assign({}, argvMock), { config: '/path/redocly.yaml', extends: ['some/path'] }), versionMock);
51
- expect(openapi_core_1.loadConfig).toHaveBeenCalledWith('/path/redocly.yaml', ['some/path'], undefined);
56
+ yield lint_1.handleLint(Object.assign(Object.assign({}, argvMock), { config: 'redocly.yaml', extends: ['some/path'] }), versionMock);
57
+ expect(openapi_core_1.loadConfig).toHaveBeenCalledWith('redocly.yaml', ['some/path'], undefined);
52
58
  }));
53
59
  it('should call mergedConfig with clear ignore if `generate-ignore-file` argv', () => __awaiter(void 0, void 0, void 0, function* () {
54
60
  yield lint_1.handleLint(Object.assign(Object.assign({}, argvMock), { 'generate-ignore-file': true }), versionMock);
@@ -65,8 +71,8 @@ describe('handleLint', () => {
65
71
  it('should call skipRules,skipPreprocessors and addIgnore with argv', () => __awaiter(void 0, void 0, void 0, function* () {
66
72
  openapi_core_1.lint.mockResolvedValueOnce(['problem']);
67
73
  yield lint_1.handleLint(Object.assign(Object.assign({}, argvMock), { 'skip-preprocessor': ['preprocessor'], 'skip-rule': ['rule'], 'generate-ignore-file': true }), versionMock);
68
- expect(config_1.ConfigFixture.lint.skipRules).toHaveBeenCalledWith(['rule']);
69
- expect(config_1.ConfigFixture.lint.skipPreprocessors).toHaveBeenCalledWith(['preprocessor']);
74
+ expect(config_1.ConfigFixture.styleguide.skipRules).toHaveBeenCalledWith(['rule']);
75
+ expect(config_1.ConfigFixture.styleguide.skipPreprocessors).toHaveBeenCalledWith(['preprocessor']);
70
76
  }));
71
77
  it('should call formatProblems and getExecutionTime with argv', () => __awaiter(void 0, void 0, void 0, function* () {
72
78
  openapi_core_1.lint.mockResolvedValueOnce(['problem']);
@@ -83,7 +89,7 @@ describe('handleLint', () => {
83
89
  it('should catch error in handleError if something fails', () => __awaiter(void 0, void 0, void 0, function* () {
84
90
  openapi_core_1.lint.mockRejectedValueOnce('error');
85
91
  yield lint_1.handleLint(argvMock, versionMock);
86
- expect(utils_1.handleError).toHaveBeenCalledWith('error', '');
92
+ expect(utils_1.handleError).toHaveBeenCalledWith('error', 'openapi.yaml');
87
93
  }));
88
94
  });
89
95
  describe('erros and warning handle after lint stage', () => {
@@ -34,7 +34,7 @@ describe('push-with-region', () => {
34
34
  redoclyClient.domain = 'redoc.ly';
35
35
  yield push_1.handlePush({
36
36
  upsert: true,
37
- entrypoint: 'spec.json',
37
+ api: 'spec.json',
38
38
  destination: '@org/my-api@1.0.0',
39
39
  branchName: 'test',
40
40
  });
@@ -45,7 +45,7 @@ describe('push-with-region', () => {
45
45
  redoclyClient.domain = 'eu.redocly.com';
46
46
  yield push_1.handlePush({
47
47
  upsert: true,
48
- entrypoint: 'spec.json',
48
+ api: 'spec.json',
49
49
  destination: '@org/my-api@1.0.0',
50
50
  branchName: 'test',
51
51
  });
@@ -30,10 +30,10 @@ describe('push', () => {
30
30
  it('pushes definition', () => __awaiter(void 0, void 0, void 0, function* () {
31
31
  yield push_1.handlePush({
32
32
  upsert: true,
33
- entrypoint: 'spec.json',
33
+ api: 'spec.json',
34
34
  destination: '@org/my-api@1.0.0',
35
35
  branchName: 'test',
36
- 'public': true,
36
+ public: true,
37
37
  'batch-id': '123',
38
38
  'batch-size': 2,
39
39
  });
@@ -55,10 +55,10 @@ describe('push', () => {
55
55
  it('fails if batchId value is an empty string', () => __awaiter(void 0, void 0, void 0, function* () {
56
56
  yield push_1.handlePush({
57
57
  upsert: true,
58
- entrypoint: 'spec.json',
58
+ api: 'spec.json',
59
59
  destination: '@org/my-api@1.0.0',
60
60
  branchName: 'test',
61
- 'public': true,
61
+ public: true,
62
62
  'batch-id': ' ',
63
63
  'batch-size': 2,
64
64
  });
@@ -67,10 +67,10 @@ describe('push', () => {
67
67
  it('fails if batchSize value is less than 2', () => __awaiter(void 0, void 0, void 0, function* () {
68
68
  yield push_1.handlePush({
69
69
  upsert: true,
70
- entrypoint: 'spec.json',
70
+ api: 'spec.json',
71
71
  destination: '@org/my-api@1.0.0',
72
72
  branchName: 'test',
73
- 'public': true,
73
+ public: true,
74
74
  'batch-id': '123',
75
75
  'batch-size': 1,
76
76
  });
@@ -81,23 +81,23 @@ describe('transformPush', () => {
81
81
  it('should adapt the existing syntax', () => {
82
82
  const cb = jest.fn();
83
83
  push_1.transformPush(cb)({
84
- maybeEntrypointOrAliasOrDestination: 'openapi.yaml',
84
+ maybeApiOrDestination: 'openapi.yaml',
85
85
  maybeDestination: '@testing_org/main@v1',
86
86
  });
87
87
  expect(cb).toBeCalledWith({
88
- entrypoint: 'openapi.yaml',
88
+ api: 'openapi.yaml',
89
89
  destination: '@testing_org/main@v1',
90
90
  });
91
91
  });
92
92
  it('should adapt the existing syntax (including branchName)', () => {
93
93
  const cb = jest.fn();
94
94
  push_1.transformPush(cb)({
95
- maybeEntrypointOrAliasOrDestination: 'openapi.yaml',
95
+ maybeApiOrDestination: 'openapi.yaml',
96
96
  maybeDestination: '@testing_org/main@v1',
97
97
  maybeBranchName: 'other',
98
98
  });
99
99
  expect(cb).toBeCalledWith({
100
- entrypoint: 'openapi.yaml',
100
+ api: 'openapi.yaml',
101
101
  destination: '@testing_org/main@v1',
102
102
  branchName: 'other',
103
103
  });
@@ -105,13 +105,13 @@ describe('transformPush', () => {
105
105
  it('should use --branch option firstly', () => {
106
106
  const cb = jest.fn();
107
107
  push_1.transformPush(cb)({
108
- maybeEntrypointOrAliasOrDestination: 'openapi.yaml',
108
+ maybeApiOrDestination: 'openapi.yaml',
109
109
  maybeDestination: '@testing_org/main@v1',
110
110
  maybeBranchName: 'other',
111
111
  branch: 'priority-branch',
112
112
  });
113
113
  expect(cb).toBeCalledWith({
114
- entrypoint: 'openapi.yaml',
114
+ api: 'openapi.yaml',
115
115
  destination: '@testing_org/main@v1',
116
116
  branchName: 'priority-branch',
117
117
  });
@@ -119,7 +119,7 @@ describe('transformPush', () => {
119
119
  it('should work for a destination only', () => {
120
120
  const cb = jest.fn();
121
121
  push_1.transformPush(cb)({
122
- maybeEntrypointOrAliasOrDestination: '@testing_org/main@v1',
122
+ maybeApiOrDestination: '@testing_org/main@v1',
123
123
  });
124
124
  expect(cb).toBeCalledWith({
125
125
  destination: '@testing_org/main@v1',
@@ -128,12 +128,12 @@ describe('transformPush', () => {
128
128
  it('should accept aliases for the old syntax', () => {
129
129
  const cb = jest.fn();
130
130
  push_1.transformPush(cb)({
131
- maybeEntrypointOrAliasOrDestination: 'alias',
131
+ maybeApiOrDestination: 'alias',
132
132
  maybeDestination: '@testing_org/main@v1',
133
133
  });
134
134
  expect(cb).toBeCalledWith({
135
135
  destination: '@testing_org/main@v1',
136
- entrypoint: 'alias',
136
+ api: 'alias',
137
137
  });
138
138
  });
139
139
  it('should accept no arguments at all', () => {
@@ -164,7 +164,7 @@ describe('getDestinationProps', () => {
164
164
  expect(push_1.getDestinationProps('main@v1', undefined)).toEqual([, 'main', 'v1']);
165
165
  });
166
166
  });
167
- describe('getApiEntrypoint', () => {
167
+ describe('getApiRoot', () => {
168
168
  let config = {
169
169
  apis: {
170
170
  'main@v1': {
@@ -176,9 +176,9 @@ describe('getApiEntrypoint', () => {
176
176
  },
177
177
  };
178
178
  it('should resolve the correct api for a valid name & version', () => {
179
- expect(push_1.getApiEntrypoint({ name: 'main', version: 'v1', config })).toEqual('openapi.yaml');
179
+ expect(push_1.getApiRoot({ name: 'main', version: 'v1', config })).toEqual('openapi.yaml');
180
180
  });
181
181
  it('should resolve the latest version of api if there is no matching version', () => {
182
- expect(push_1.getApiEntrypoint({ name: 'main', version: 'latest', config })).toEqual('latest.yaml');
182
+ expect(push_1.getApiRoot({ name: 'main', version: 'latest', config })).toEqual('latest.yaml');
183
183
  });
184
184
  });
@@ -1,7 +1,7 @@
1
1
  /// <reference types="jest" />
2
2
  export declare const ConfigFixture: {
3
3
  configFile: null;
4
- lint: {
4
+ styleguide: {
5
5
  addIgnore: jest.Mock<any, any>;
6
6
  skipRules: jest.Mock<any, any>;
7
7
  skipPreprocessors: jest.Mock<any, any>;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConfigFixture = void 0;
4
4
  exports.ConfigFixture = {
5
5
  configFile: null,
6
- lint: {
6
+ styleguide: {
7
7
  addIgnore: jest.fn(),
8
8
  skipRules: jest.fn(),
9
9
  skipPreprocessors: jest.fn(),
@@ -1,20 +1,12 @@
1
- import { OutputFormat } from '@redocly/openapi-core';
2
- import { OutputExtensions } from '../types';
3
- export declare function handleBundle(argv: {
4
- entrypoints: string[];
1
+ import type { CommonOptions, OutputExtensions, Skips } from '../types';
2
+ export declare type BundleOptions = CommonOptions & Skips & {
5
3
  output?: string;
6
4
  ext: OutputExtensions;
7
- 'max-problems'?: number;
8
- 'skip-rule'?: string[];
9
- 'skip-preprocessor'?: string[];
10
- 'skip-decorator'?: string[];
11
5
  dereferenced?: boolean;
12
6
  force?: boolean;
13
- config?: string;
14
7
  lint?: boolean;
15
- format: OutputFormat;
16
8
  metafile?: string;
17
- extends?: string[];
18
9
  'remove-unused-components'?: boolean;
19
10
  'keep-url-references'?: boolean;
20
- }, version: string): Promise<void>;
11
+ };
12
+ export declare function handleBundle(argv: BundleOptions, version: string): Promise<void>;
@@ -31,19 +31,20 @@ function handleBundle(argv, version) {
31
31
  return __awaiter(this, void 0, void 0, function* () {
32
32
  const config = yield openapi_core_1.loadConfig(argv.config, argv.extends);
33
33
  const removeUnusedComponents = argv['remove-unused-components'] &&
34
- !((_b = (_a = config.rawConfig.lint) === null || _a === void 0 ? void 0 : _a.decorators) === null || _b === void 0 ? void 0 : _b.hasOwnProperty('remove-unused-components'));
35
- const entrypoints = yield utils_1.getFallbackEntryPointsOrExit(argv.entrypoints, config);
34
+ !((_b = (_a = config.rawConfig.styleguide) === null || _a === void 0 ? void 0 : _a.decorators) === null || _b === void 0 ? void 0 : _b.hasOwnProperty('remove-unused-components'));
35
+ const apis = yield utils_1.getFallbackApisOrExit(argv.apis, config);
36
36
  const totals = { errors: 0, warnings: 0, ignored: 0 };
37
37
  const maxProblems = argv['max-problems'];
38
- for (const { path, alias } of entrypoints) {
38
+ for (const { path, alias } of apis) {
39
39
  try {
40
40
  const startedAt = perf_hooks_1.performance.now();
41
41
  const resolvedConfig = openapi_core_1.getMergedConfig(config, alias);
42
- resolvedConfig.lint.skipRules(argv['skip-rule']);
43
- resolvedConfig.lint.skipPreprocessors(argv['skip-preprocessor']);
44
- resolvedConfig.lint.skipDecorators(argv['skip-decorator']);
42
+ const { styleguide } = resolvedConfig;
43
+ styleguide.skipRules(argv['skip-rule']);
44
+ styleguide.skipPreprocessors(argv['skip-preprocessor']);
45
+ styleguide.skipDecorators(argv['skip-decorator']);
45
46
  if (argv.lint) {
46
- if (config.lint.recommendedFallback) {
47
+ if (config.styleguide.recommendedFallback) {
47
48
  process.stderr.write(`No configurations were defined in extends -- using built in ${colorette_1.blue('recommended')} configuration by default.\n${colorette_1.red('Warning! This default behavior is going to be deprecated soon.')}\n\n`);
48
49
  }
49
50
  const results = yield openapi_core_1.lint({
@@ -71,7 +72,7 @@ function handleBundle(argv, version) {
71
72
  keepUrlRefs: argv['keep-url-references'],
72
73
  }), { bundle: result, problems } = _e, meta = __rest(_e, ["bundle", "problems"]);
73
74
  const fileTotals = openapi_core_1.getTotals(problems);
74
- const { outputFile, ext } = utils_1.getOutputFileName(path, entrypoints.length, argv.output, argv.ext);
75
+ const { outputFile, ext } = utils_1.getOutputFileName(path, apis.length, argv.output, argv.ext);
75
76
  if (fileTotals.errors === 0 || argv.force) {
76
77
  if (!argv.output) {
77
78
  const output = utils_1.dumpBundle(result.parsed, argv.ext || 'yaml', argv.dereferenced);
@@ -92,8 +93,8 @@ function handleBundle(argv, version) {
92
93
  version,
93
94
  });
94
95
  if (argv.metafile) {
95
- if (entrypoints.length > 1) {
96
- process.stderr.write(colorette_1.yellow(`[WARNING] "--metafile" cannot be used with multiple entrypoints. Skipping...`));
96
+ if (apis.length > 1) {
97
+ process.stderr.write(colorette_1.yellow(`[WARNING] "--metafile" cannot be used with multiple apis. Skipping...`));
97
98
  }
98
99
  {
99
100
  fs_1.writeFileSync(argv.metafile, JSON.stringify(meta), 'utf-8');
@@ -120,7 +121,7 @@ function handleBundle(argv, version) {
120
121
  utils_1.handleError(e, path);
121
122
  }
122
123
  }
123
- utils_1.printUnusedWarnings(config.lint);
124
+ utils_1.printUnusedWarnings(config.styleguide);
124
125
  // defer process exit to allow STDOUT pipe to flush
125
126
  // see https://github.com/nodejs/node-v0.x-archive/issues/3737#issuecomment-19156072
126
127
  process.once('exit', () => process.exit(totals.errors === 0 || argv.force ? 0 : 1));
@@ -1,5 +1,5 @@
1
1
  declare type JoinArgv = {
2
- entrypoints: string[];
2
+ apis: string[];
3
3
  lint?: boolean;
4
4
  'prefix-tags-with-info-prop'?: string;
5
5
  'prefix-tags-with-filename'?: boolean;