diff --git a/.gitignore b/.gitignore index 5b8a7c8b336..d9a57e16e83 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,9 @@ node_modules test.asyncapi-cli asyncapi.json test/fixtures/minimaltemplate/__transpiled +test/fixtures/specification-conv.yml +test/fixtures/specification-conv.yaml +test/fixtures/specification-conv.json .vscode /action/ diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000000..dc2fb828f03 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "singleQuote": true +} \ No newline at end of file diff --git a/assets/create-glee-app/templates/tutorial/package-lock.json b/assets/create-glee-app/templates/tutorial/package-lock.json index b3f97901a43..843c4583ae3 100644 --- a/assets/create-glee-app/templates/tutorial/package-lock.json +++ b/assets/create-glee-app/templates/tutorial/package-lock.json @@ -5459,9 +5459,9 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.5.tgz", + "integrity": "sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", diff --git a/assets/create-template/templates/default/package-lock.json b/assets/create-template/templates/default/package-lock.json index 183724bc880..9afc1cf3c47 100644 --- a/assets/create-template/templates/default/package-lock.json +++ b/assets/create-template/templates/default/package-lock.json @@ -91,11 +91,11 @@ } }, "node_modules/@asyncapi/parser": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-3.2.2.tgz", - "integrity": "sha512-ved4ja3ANs6BcRhWLbK/A7JIhJyMQBYdV1GZwo6Ptf+qBkGIdvV3dt8M4T6TZqtIbUI2NOvmO2YUqtaPWTudgA==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-3.4.0.tgz", + "integrity": "sha512-Sxn74oHiZSU6+cVeZy62iPZMFMvKp4jupMFHelSICCMw1qELmUHPvuZSr+ZHDmNGgHcEpzJM5HN02kR7T4g+PQ==", "dependencies": { - "@asyncapi/specs": "^6.6.0", + "@asyncapi/specs": "^6.8.0", "@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0", "@stoplight/json": "3.21.0", "@stoplight/json-ref-readers": "^1.2.2", @@ -112,14 +112,14 @@ "ajv-formats": "^2.1.1", "avsc": "^5.7.5", "js-yaml": "^4.1.0", - "jsonpath-plus": "^7.2.0", + "jsonpath-plus": "^10.0.0", "node-fetch": "2.6.7" } }, "node_modules/@asyncapi/specs": { - "version": "6.7.1", - "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-6.7.1.tgz", - "integrity": "sha512-jEaW2vgAwD9GboCdO/TI1zN2k+iowL8YFYwiZwTIr4U4KDmsgo3BLypScl6Jl4+IvY9RdsWE67nuzVX7jooiqQ==", + "version": "6.8.0", + "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-6.8.0.tgz", + "integrity": "sha512-1i6xs8+IOh6U5T7yH+bCMGQBF+m7kP/NpwyAlt++XaDQutoGCgACf24mQBgcDVqDWWoY81evQv+9ABvw0BviVg==", "dependencies": { "@types/json-schema": "^7.0.11" } @@ -1813,6 +1813,17 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@jsep-plugin/assignment": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@jsep-plugin/assignment/-/assignment-1.3.0.tgz", + "integrity": "sha512-VVgV+CXrhbMI3aSusQyclHkenWSAm95WaiKrMxRFam3JSUiIaQjoMIw2sEs/OX4XifnqeQUN4DYbJjlA8EfktQ==", + "engines": { + "node": ">= 10.16.0" + }, + "peerDependencies": { + "jsep": "^0.4.0||^1.0.0" + } + }, "node_modules/@jsep-plugin/regex": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@jsep-plugin/regex/-/regex-1.0.3.tgz", @@ -3344,11 +3355,20 @@ "integrity": "sha512-o6/yDBYccGvTz1+QFevz6l6OBZ2+fMVu2JZ9CIhzsYRX4mjaK5IyX9eldUdCmga16zlgQxyrj5pt9kzuj2C02w==" }, "node_modules/jsonpath-plus": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-7.2.0.tgz", - "integrity": "sha512-zBfiUPM5nD0YZSBT/o/fbCUlCcepMIdP0CJZxM1+KgA4f2T206f6VAg9e7mX35+KlMaIc5qXW34f3BnwJ3w+RA==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-10.1.0.tgz", + "integrity": "sha512-gHfV1IYqH8uJHYVTs8BJX1XKy2/rR93+f8QQi0xhx95aCiXn1ettYAd5T+7FU6wfqyDoX/wy0pm/fL3jOKJ9Lg==", + "dependencies": { + "@jsep-plugin/assignment": "^1.2.1", + "@jsep-plugin/regex": "^1.0.3", + "jsep": "^1.3.9" + }, + "bin": { + "jsonpath": "bin/jsonpath-cli.js", + "jsonpath-plus": "bin/jsonpath-cli.js" + }, "engines": { - "node": ">=12.0.0" + "node": ">=18.0.0" } }, "node_modules/jsonpointer": { diff --git a/docs/usage.md b/docs/usage.md index 502d70fff85..2e2412cc95c 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -27,7 +27,7 @@ $ npm install -g @asyncapi/cli $ asyncapi COMMAND running command... $ asyncapi (--version) -@asyncapi/cli/2.8.1 linux-x64 node-v18.20.4 +@asyncapi/cli/2.9.0 linux-x64 node-v18.20.4 $ asyncapi --help [COMMAND] USAGE $ asyncapi COMMAND @@ -52,6 +52,7 @@ USAGE * [`asyncapi config versions`](#asyncapi-config-versions) * [`asyncapi convert [SPEC-FILE]`](#asyncapi-convert-spec-file) * [`asyncapi diff OLD NEW`](#asyncapi-diff-old-new) +* [`asyncapi format [SPEC-FILE]`](#asyncapi-format-spec-file) * [`asyncapi generate`](#asyncapi-generate) * [`asyncapi generate fromTemplate ASYNCAPI TEMPLATE`](#asyncapi-generate-fromtemplate-asyncapi-template) * [`asyncapi generate models LANGUAGE FILE`](#asyncapi-generate-models-language-file) @@ -99,7 +100,7 @@ EXAMPLES $ asyncapi bundle ./asyncapi.yaml -o final-asyncapi.yaml --base ../public-api/main.yaml --baseDir ./social-media/comments-service ``` -_See code: [src/commands/bundle.ts](https://github.com/asyncapi/cli/blob/v2.8.1/src/commands/bundle.ts)_ +_See code: [src/commands/bundle.ts](https://github.com/asyncapi/cli/blob/v2.9.0/src/commands/bundle.ts)_ ## `asyncapi config` @@ -113,7 +114,7 @@ DESCRIPTION CLI config settings ``` -_See code: [src/commands/config/index.ts](https://github.com/asyncapi/cli/blob/v2.8.1/src/commands/config/index.ts)_ +_See code: [src/commands/config/index.ts](https://github.com/asyncapi/cli/blob/v2.9.0/src/commands/config/index.ts)_ ## `asyncapi config analytics` @@ -133,7 +134,7 @@ DESCRIPTION Enable or disable analytics for metrics collection ``` -_See code: [src/commands/config/analytics.ts](https://github.com/asyncapi/cli/blob/v2.8.1/src/commands/config/analytics.ts)_ +_See code: [src/commands/config/analytics.ts](https://github.com/asyncapi/cli/blob/v2.9.0/src/commands/config/analytics.ts)_ ## `asyncapi config context` @@ -147,7 +148,7 @@ DESCRIPTION Manage short aliases for full paths to AsyncAPI documents ``` -_See code: [src/commands/config/context/index.ts](https://github.com/asyncapi/cli/blob/v2.8.1/src/commands/config/context/index.ts)_ +_See code: [src/commands/config/context/index.ts](https://github.com/asyncapi/cli/blob/v2.9.0/src/commands/config/context/index.ts)_ ## `asyncapi config context add CONTEXT-NAME SPEC-FILE-PATH` @@ -169,7 +170,7 @@ DESCRIPTION Add a context to the store ``` -_See code: [src/commands/config/context/add.ts](https://github.com/asyncapi/cli/blob/v2.8.1/src/commands/config/context/add.ts)_ +_See code: [src/commands/config/context/add.ts](https://github.com/asyncapi/cli/blob/v2.9.0/src/commands/config/context/add.ts)_ ## `asyncapi config context current` @@ -186,7 +187,7 @@ DESCRIPTION Shows the current context that is being used ``` -_See code: [src/commands/config/context/current.ts](https://github.com/asyncapi/cli/blob/v2.8.1/src/commands/config/context/current.ts)_ +_See code: [src/commands/config/context/current.ts](https://github.com/asyncapi/cli/blob/v2.9.0/src/commands/config/context/current.ts)_ ## `asyncapi config context edit CONTEXT-NAME NEW-SPEC-FILE-PATH` @@ -207,7 +208,7 @@ DESCRIPTION Edit a context in the store ``` -_See code: [src/commands/config/context/edit.ts](https://github.com/asyncapi/cli/blob/v2.8.1/src/commands/config/context/edit.ts)_ +_See code: [src/commands/config/context/edit.ts](https://github.com/asyncapi/cli/blob/v2.9.0/src/commands/config/context/edit.ts)_ ## `asyncapi config context init [CONTEXT-FILE-PATH]` @@ -230,7 +231,7 @@ DESCRIPTION Initialize context ``` -_See code: [src/commands/config/context/init.ts](https://github.com/asyncapi/cli/blob/v2.8.1/src/commands/config/context/init.ts)_ +_See code: [src/commands/config/context/init.ts](https://github.com/asyncapi/cli/blob/v2.9.0/src/commands/config/context/init.ts)_ ## `asyncapi config context list` @@ -247,7 +248,7 @@ DESCRIPTION List all the stored contexts in the store ``` -_See code: [src/commands/config/context/list.ts](https://github.com/asyncapi/cli/blob/v2.8.1/src/commands/config/context/list.ts)_ +_See code: [src/commands/config/context/list.ts](https://github.com/asyncapi/cli/blob/v2.9.0/src/commands/config/context/list.ts)_ ## `asyncapi config context remove CONTEXT-NAME` @@ -267,7 +268,7 @@ DESCRIPTION Delete a context from the store ``` -_See code: [src/commands/config/context/remove.ts](https://github.com/asyncapi/cli/blob/v2.8.1/src/commands/config/context/remove.ts)_ +_See code: [src/commands/config/context/remove.ts](https://github.com/asyncapi/cli/blob/v2.9.0/src/commands/config/context/remove.ts)_ ## `asyncapi config context use CONTEXT-NAME` @@ -287,7 +288,7 @@ DESCRIPTION Set a context as current ``` -_See code: [src/commands/config/context/use.ts](https://github.com/asyncapi/cli/blob/v2.8.1/src/commands/config/context/use.ts)_ +_See code: [src/commands/config/context/use.ts](https://github.com/asyncapi/cli/blob/v2.9.0/src/commands/config/context/use.ts)_ ## `asyncapi config versions` @@ -304,7 +305,7 @@ DESCRIPTION Show versions of AsyncAPI tools used ``` -_See code: [src/commands/config/versions.ts](https://github.com/asyncapi/cli/blob/v2.8.1/src/commands/config/versions.ts)_ +_See code: [src/commands/config/versions.ts](https://github.com/asyncapi/cli/blob/v2.9.0/src/commands/config/versions.ts)_ ## `asyncapi convert [SPEC-FILE]` @@ -332,7 +333,7 @@ DESCRIPTION Convert asyncapi documents older to newer versions or OpenAPI/postman-collection documents to AsyncAPI ``` -_See code: [src/commands/convert.ts](https://github.com/asyncapi/cli/blob/v2.8.1/src/commands/convert.ts)_ +_See code: [src/commands/convert.ts](https://github.com/asyncapi/cli/blob/v2.9.0/src/commands/convert.ts)_ ## `asyncapi diff OLD NEW` @@ -373,7 +374,30 @@ DESCRIPTION Find diff between two asyncapi files ``` -_See code: [src/commands/diff.ts](https://github.com/asyncapi/cli/blob/v2.8.1/src/commands/diff.ts)_ +_See code: [src/commands/diff.ts](https://github.com/asyncapi/cli/blob/v2.9.0/src/commands/diff.ts)_ + +## `asyncapi format [SPEC-FILE]` + +Convert asyncapi documents from any format to yaml, yml or JSON + +``` +USAGE + $ asyncapi format [SPEC-FILE] -f yaml|yml|json [-h] [-o ] + +ARGUMENTS + SPEC-FILE spec path, url, or context-name + +FLAGS + -f, --format=