@redocly/cli 1.10.6 → 1.12.0

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 (39) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/lib/__tests__/commands/bundle.test.js +3 -32
  3. package/lib/__tests__/commands/join.test.js +0 -11
  4. package/lib/__tests__/utils.test.js +3 -3
  5. package/lib/cms/api/types.d.ts +22 -11
  6. package/lib/cms/commands/__tests__/push-status.test.js +338 -29
  7. package/lib/cms/commands/__tests__/push.test.js +32 -2
  8. package/lib/cms/commands/__tests__/utils.test.d.ts +1 -0
  9. package/lib/cms/commands/__tests__/utils.test.js +60 -0
  10. package/lib/cms/commands/push-status.d.ts +14 -4
  11. package/lib/cms/commands/push-status.js +160 -90
  12. package/lib/cms/commands/push.d.ts +6 -2
  13. package/lib/cms/commands/push.js +8 -2
  14. package/lib/cms/commands/utils.d.ts +22 -0
  15. package/lib/cms/commands/utils.js +53 -0
  16. package/lib/commands/bundle.d.ts +1 -4
  17. package/lib/commands/bundle.js +2 -32
  18. package/lib/commands/join.d.ts +0 -3
  19. package/lib/commands/join.js +13 -36
  20. package/lib/index.js +69 -27
  21. package/lib/utils/miscellaneous.js +5 -4
  22. package/lib/wrapper.d.ts +1 -1
  23. package/package.json +2 -2
  24. package/src/__tests__/commands/bundle.test.ts +4 -37
  25. package/src/__tests__/commands/join.test.ts +0 -17
  26. package/src/__tests__/utils.test.ts +3 -3
  27. package/src/cms/api/types.ts +19 -12
  28. package/src/cms/commands/__tests__/push-status.test.ts +473 -47
  29. package/src/cms/commands/__tests__/push.test.ts +40 -2
  30. package/src/cms/commands/__tests__/utils.test.ts +62 -0
  31. package/src/cms/commands/push-status.ts +242 -120
  32. package/src/cms/commands/push.ts +21 -5
  33. package/src/cms/commands/utils.ts +52 -0
  34. package/src/commands/bundle.ts +3 -53
  35. package/src/commands/join.ts +13 -49
  36. package/src/index.ts +89 -28
  37. package/src/utils/miscellaneous.ts +5 -4
  38. package/src/wrapper.ts +1 -1
  39. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @redocly/cli
2
2
 
3
+ ## 1.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added return values for the `push` and `push-status` commands.
8
+
9
+ ### Patch Changes
10
+
11
+ - Fixed handling of wildcards on Windows ([#1521](https://github.com/Redocly/redocly-cli/issues/1521)).
12
+ - Updated @redocly/openapi-core to v1.12.0.
13
+
14
+ ## 1.11.0
15
+
16
+ ### Minor Changes
17
+
18
+ - Removed additional operations from the `join` command; use `lint` and/or `bundle` for operations such as `lint` and `decorate`.
19
+ - Removed lint support from the bundle command to support a wider range of use cases. Users should update to [run lint and bundle separately](https://redocly.com/docs/cli/guides/lint-and-bundle/).
20
+ - Added support for a `github-actions` output format for the `lint` command to annotate reported problems on files when used in a GitHub Actions workflow.
21
+
22
+ ### Patch Changes
23
+
24
+ - Fixed [`no-invalid-media-type-examples`](https://redocly.com/docs/cli/rules/no-invalid-media-type-examples/) rule `externalValue` example validation.
25
+ - Updated @redocly/openapi-core to v1.11.0.
26
+
3
27
  ## 1.10.6
4
28
 
5
29
  ### Patch Changes
@@ -28,18 +28,15 @@ describe('bundle', () => {
28
28
  jest.spyOn(process.stderr, 'write').mockImplementation(() => true);
29
29
  });
30
30
  afterEach(() => {
31
- openapi_core_1.lint.mockClear();
32
31
  openapi_core_1.bundle.mockClear();
33
32
  openapi_core_1.getTotals.mockReset();
34
33
  });
35
- it('bundles definitions w/o linting', () => __awaiter(void 0, void 0, void 0, function* () {
34
+ it('bundles definitions', () => __awaiter(void 0, void 0, void 0, function* () {
36
35
  const apis = ['foo.yaml', 'bar.yaml'];
37
36
  yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
38
37
  apis,
39
38
  ext: 'yaml',
40
- format: 'codeframe',
41
39
  });
42
- expect(openapi_core_1.lint).toBeCalledTimes(0);
43
40
  expect(openapi_core_1.bundle).toBeCalledTimes(apis.length);
44
41
  }));
45
42
  it('exits with code 0 when bundles definitions', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -47,39 +44,20 @@ describe('bundle', () => {
47
44
  yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
48
45
  apis,
49
46
  ext: 'yaml',
50
- format: 'codeframe',
51
47
  });
52
48
  yield (exitCb === null || exitCb === void 0 ? void 0 : exitCb());
53
49
  expect(processExitMock).toHaveBeenCalledWith(0);
54
50
  }));
55
- it('bundles definitions w/ linting', () => __awaiter(void 0, void 0, void 0, function* () {
56
- const apis = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
57
- openapi_core_1.getTotals.mockReturnValue({
58
- errors: 0,
59
- warnings: 0,
60
- ignored: 0,
61
- });
62
- yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
63
- apis,
64
- ext: 'yaml',
65
- format: 'codeframe',
66
- lint: true,
67
- });
68
- expect(openapi_core_1.lint).toBeCalledTimes(apis.length);
69
- expect(openapi_core_1.bundle).toBeCalledTimes(apis.length);
70
- }));
71
- it('exits with code 0 when bundles definitions w/linting w/o errors', () => __awaiter(void 0, void 0, void 0, function* () {
51
+ it('exits with code 0 when bundles definitions w/o errors', () => __awaiter(void 0, void 0, void 0, function* () {
72
52
  const apis = ['foo.yaml', 'bar.yaml', 'foobar.yaml'];
73
53
  yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
74
54
  apis,
75
55
  ext: 'yaml',
76
- format: 'codeframe',
77
- lint: true,
78
56
  });
79
57
  yield (exitCb === null || exitCb === void 0 ? void 0 : exitCb());
80
58
  expect(processExitMock).toHaveBeenCalledWith(0);
81
59
  }));
82
- it('exits with code 1 when bundles definitions w/linting w/errors', () => __awaiter(void 0, void 0, void 0, function* () {
60
+ it('exits with code 1 when bundles definitions w/errors', () => __awaiter(void 0, void 0, void 0, function* () {
83
61
  const apis = ['foo.yaml'];
84
62
  openapi_core_1.getTotals.mockReturnValue({
85
63
  errors: 1,
@@ -89,10 +67,7 @@ describe('bundle', () => {
89
67
  yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
90
68
  apis,
91
69
  ext: 'yaml',
92
- format: 'codeframe',
93
- lint: true,
94
70
  });
95
- expect(openapi_core_1.lint).toBeCalledTimes(apis.length);
96
71
  yield (exitCb === null || exitCb === void 0 ? void 0 : exitCb());
97
72
  expect(processExitMock).toHaveBeenCalledWith(1);
98
73
  }));
@@ -104,8 +79,6 @@ describe('bundle', () => {
104
79
  yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
105
80
  apis,
106
81
  ext: 'json',
107
- format: 'codeframe',
108
- lint: false,
109
82
  });
110
83
  expect(miscellaneous_1.handleError).toHaveBeenCalledTimes(1);
111
84
  expect(miscellaneous_1.handleError).toHaveBeenCalledWith(new Error('Invalid definition'), 'invalid.json');
@@ -120,8 +93,6 @@ describe('bundle', () => {
120
93
  yield (0, wrapper_1.commandWrapper)(bundle_1.handleBundle)({
121
94
  apis,
122
95
  ext: 'yaml',
123
- format: 'codeframe',
124
- lint: false,
125
96
  });
126
97
  expect(miscellaneous_1.handleError).toHaveBeenCalledTimes(0);
127
98
  }));
@@ -94,17 +94,6 @@ describe('handleJoin', () => {
94
94
  expect(config.styleguide.skipDecorators).toHaveBeenCalled();
95
95
  expect(config.styleguide.skipPreprocessors).toHaveBeenCalled();
96
96
  }));
97
- it('should not call skipDecorators and skipPreprocessors', () => __awaiter(void 0, void 0, void 0, function* () {
98
- openapi_core_1.detectSpec.mockReturnValue('oas3_0');
99
- yield (0, join_1.handleJoin)({
100
- apis: ['first.yaml', 'second.yaml'],
101
- decorate: true,
102
- preprocess: true,
103
- }, config_1.ConfigFixture, 'cli-version');
104
- const config = (0, openapi_core_2.loadConfig)();
105
- expect(config.styleguide.skipDecorators).not.toHaveBeenCalled();
106
- expect(config.styleguide.skipPreprocessors).not.toHaveBeenCalled();
107
- }));
108
97
  it('should handle join with prefix-components-with-info-prop and null values', () => __awaiter(void 0, void 0, void 0, function* () {
109
98
  openapi_core_1.detectSpec.mockReturnValue('oas3_0');
110
99
  yield (0, join_1.handleJoin)({
@@ -348,13 +348,13 @@ describe('handleErrors', () => {
348
348
  jest.clearAllMocks();
349
349
  });
350
350
  it('should handle ResolveError', () => {
351
- const resolveError = new openapi_core_1.ResolveError(new Error('File not found'));
351
+ const resolveError = new openapi_core_1.ResolveError(new Error('File not found.'));
352
352
  expect(() => (0, miscellaneous_1.handleError)(resolveError, ref)).toThrowError(miscellaneous_1.HandledError);
353
353
  expect(redColoretteMocks).toHaveBeenCalledTimes(1);
354
354
  expect(process.stderr.write).toHaveBeenCalledWith(`Failed to resolve API description at openapi/test.yaml:\n\n - File not found.\n\n`);
355
355
  });
356
356
  it('should handle YamlParseError', () => {
357
- const yamlParseError = new openapi_core_1.YamlParseError(new Error('Invalid yaml'), {});
357
+ const yamlParseError = new openapi_core_1.YamlParseError(new Error('Invalid yaml.'), {});
358
358
  expect(() => (0, miscellaneous_1.handleError)(yamlParseError, ref)).toThrowError(miscellaneous_1.HandledError);
359
359
  expect(redColoretteMocks).toHaveBeenCalledTimes(1);
360
360
  expect(process.stderr.write).toHaveBeenCalledWith(`Failed to parse API description at openapi/test.yaml:\n\n - Invalid yaml.\n\n`);
@@ -372,7 +372,7 @@ describe('handleErrors', () => {
372
372
  expect(process.stderr.write).toHaveBeenCalledWith('Syntax error: Unexpected identifier test stack\n\n');
373
373
  });
374
374
  it('should throw unknown error', () => {
375
- const testError = new Error('Test error');
375
+ const testError = new Error('Test error.');
376
376
  expect(() => (0, miscellaneous_1.handleError)(testError, ref)).toThrowError(miscellaneous_1.HandledError);
377
377
  expect(process.stderr.write).toHaveBeenCalledWith(`Something went wrong when processing openapi/test.yaml:\n\n - Test error.\n\n`);
378
378
  });
@@ -44,32 +44,44 @@ export type Remote = {
44
44
  export type PushResponse = {
45
45
  id: string;
46
46
  remoteId: string;
47
+ isMainBranch: boolean;
48
+ isOutdated: boolean;
49
+ hasChanges: boolean;
50
+ replace: boolean;
51
+ scoutJobId: string | null;
52
+ uploadedFiles: Array<{
53
+ path: string;
54
+ mimeType: string;
55
+ }>;
47
56
  commit: {
48
- message: string;
49
57
  branchName: string;
50
- sha: string | null;
51
- url: string | null;
58
+ message: string;
52
59
  createdAt: string | null;
53
- namespace: string | null;
54
- repository: string | null;
60
+ namespaceId: string | null;
61
+ repositoryId: string | null;
62
+ url: string | null;
63
+ sha: string | null;
55
64
  author: {
56
65
  name: string;
57
66
  email: string;
58
67
  image: string | null;
59
68
  };
69
+ statuses: Array<{
70
+ name: string;
71
+ description: string;
72
+ status: 'pending' | 'running' | 'success' | 'failed';
73
+ url: string | null;
74
+ }>;
60
75
  };
61
76
  remote: {
62
77
  commits: {
63
- branchName: string;
64
78
  sha: string;
79
+ branchName: string;
65
80
  }[];
66
81
  };
67
- hasChanges: boolean;
68
- isOutdated: boolean;
69
- isMainBranch: boolean;
70
82
  status: PushStatusResponse;
71
83
  };
72
- type DeploymentStatusResponse = {
84
+ export type DeploymentStatusResponse = {
73
85
  deploy: {
74
86
  url: string | null;
75
87
  status: DeploymentStatus;
@@ -88,4 +100,3 @@ export type ScorecardItem = {
88
100
  };
89
101
  export type PushStatusBase = 'pending' | 'success' | 'running' | 'failed';
90
102
  export type DeploymentStatus = 'skipped' | PushStatusBase;
91
- export {};