Skip to content

Commit

Permalink
Merge branch 'master' into fix/migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
Shurtu-gal authored Dec 20, 2024
2 parents 6dadcb4 + e79294b commit a7a3079
Show file tree
Hide file tree
Showing 7 changed files with 294 additions and 46 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @asyncapi/cli

## 2.13.1

### Patch Changes

- 8ae33c4: Handle AsyncAPI v3 in diff command

## 2.13.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ runs:
using: 'docker'
# This is the image that will be used to run the action.
# IMPORTANT: The version has to be changed manually in your PRs.
image: 'docker://asyncapi/github-action-for-cli:2.13.0'
image: 'docker://asyncapi/github-action-for-cli:2.13.1'
args:
- ${{ inputs.cli_version }}
- ${{ inputs.command }}
Expand Down
21 changes: 10 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@asyncapi/cli",
"description": "All in one CLI for all AsyncAPI tools",
"version": "2.13.0",
"version": "2.13.1",
"author": "@asyncapi",
"bin": {
"asyncapi": "./bin/run_bin"
Expand All @@ -11,13 +11,13 @@
"@asyncapi/avro-schema-parser": "^3.0.23",
"@asyncapi/bundler": "^0.6.4",
"@asyncapi/converter": "^1.6.2",
"@asyncapi/diff": "^0.4.1",
"@asyncapi/diff": "^0.5.0",
"@asyncapi/generator": "^1.17.25",
"@asyncapi/modelina-cli": "^4.0.0-next.48",
"@asyncapi/openapi-schema-parser": "^3.0.24",
"@asyncapi/optimizer": "^1.0.4",
"@asyncapi/parser": "^3.3.0",
"@asyncapi/protobuf-schema-parser": "^3.3.0",
"@asyncapi/protobuf-schema-parser": "^3.4.0",
"@asyncapi/raml-dt-schema-parser": "^4.0.24",
"@asyncapi/studio": "^0.20.0",
"@clack/prompts": "^0.7.0",
Expand Down Expand Up @@ -172,4 +172,4 @@
"action:test": "cd github-action && make test"
},
"types": "lib/index.d.ts"
}
}
22 changes: 6 additions & 16 deletions src/commands/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
DiffOverrideJSONError,
} from '../core/errors/diff-error';
import { specWatcher } from '../core/globals';
import { parse, convertToOldAPI } from '../core/parser';
import { parse } from '../core/parser';

import type { SpecWatcherParams } from '../core/globals';
import { diffFlags } from '../core/flags/diff.flags';
Expand Down Expand Up @@ -57,10 +57,6 @@ export default class Diff extends Command {
try {
firstDocument = await load(firstDocumentPath);

if (firstDocument.isAsyncAPI3()) {
this.error('Diff command does not support AsyncAPI v3 yet which was your first document, please checkout https://github.com/asyncapi/diff/issues/154');
}

enableWatch(watchMode, {
spec: firstDocument,
handler: this,
Expand All @@ -83,10 +79,6 @@ export default class Diff extends Command {
try {
secondDocument = await load(secondDocumentPath);

if (secondDocument.isAsyncAPI3()) {
this.error('Diff command does not support AsyncAPI v3 yet which was your second document, please checkout https://github.com/asyncapi/diff/issues/154');
}

enableWatch(watchMode, {
spec: secondDocument,
handler: this,
Expand Down Expand Up @@ -146,9 +138,9 @@ export default class Diff extends Command {
throwOnBreakingChange(diffOutput, outputFormat);
}
} catch (error) {
if (error instanceof DiffBreakingChangeError) {
if (error instanceof DiffBreakingChangeError || error instanceof TypeError) {
this.error(error);
}
}
throw new ValidationError({
type: 'parser-error',
err: error,
Expand Down Expand Up @@ -196,15 +188,13 @@ function genericOutput(diffOutput: AsyncAPIDiff, outputType: string) {
}

async function parseDocuments(command: Command, firstDocument: Specification, secondDocument: Specification, flags: Record<string, any>) {
const { document: newFirstDocumentParsed, status: firstDocumentStatus } = await parse(command, firstDocument, flags);
const { document: newSecondDocumentParsed, status: secondDocumentStatus } = await parse(command, secondDocument, flags);
const { document: firstDocumentParsed, status: firstDocumentStatus } = await parse(command, firstDocument, flags);
const { document: secondDocumentParsed, status: secondDocumentStatus } = await parse(command, secondDocument, flags);

if (!newFirstDocumentParsed || !newSecondDocumentParsed || firstDocumentStatus === 'invalid' || secondDocumentStatus === 'invalid') {
if (!firstDocumentParsed || !secondDocumentParsed || firstDocumentStatus === 'invalid' || secondDocumentStatus === 'invalid') {
return;
}

const firstDocumentParsed = convertToOldAPI(newFirstDocumentParsed);
const secondDocumentParsed = convertToOldAPI(newSecondDocumentParsed);
return { firstDocumentParsed, secondDocumentParsed };
}

Expand Down
Loading

0 comments on commit a7a3079

Please sign in to comment.