diff --git a/.asyncapi-cli b/.asyncapi-cli new file mode 100644 index 00000000000..169c09a3f6b --- /dev/null +++ b/.asyncapi-cli @@ -0,0 +1 @@ +{"current":"eight-context","store":{"seven-context":".","eight-context":"."}} \ No newline at end of file diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 00000000000..b6d4d5393be --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json", + "changelog": ["@changesets/changelog-git", { "repo": "asyncapi/cli" }], + "commit": false, + "fixed": [], + "linked": [], + "access": "public", + "baseBranch": "master", + "updateInternalDependencies": "patch", + "privatePackages": { + "version": true, + "tag": true + } +} diff --git a/.github/workflows/if-nodejs-version-bump.yml b/.github/workflows/if-nodejs-version-bump.yml deleted file mode 100644 index 36847d803a0..00000000000 --- a/.github/workflows/if-nodejs-version-bump.yml +++ /dev/null @@ -1,69 +0,0 @@ -# This action is centrally managed in https://github.com/asyncapi/.github/ -# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo - -# It does magic only if there is package.json file in the root of the project -name: Version bump - if Node.js project - -on: - release: - types: - - published - -jobs: - version_bump: - name: Generate assets and bump NodeJS - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - # target branch of release. More info https://docs.github.com/en/rest/reference/repos#releases - # in case release is created from release branch then we need to checkout from given branch - # if @semantic-release/github is used to publish, the minimum version is 7.2.0 for proper working - ref: ${{ github.event.release.target_commitish }} - - name: Check if Node.js project and has package.json - id: packagejson - run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT - - if: steps.packagejson.outputs.exists == 'true' - name: Check package-lock version - uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master - id: lockversion - - if: steps.packagejson.outputs.exists == 'true' - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: "${{ steps.lockversion.outputs.version }}" - cache: 'npm' - cache-dependency-path: '**/package-lock.json' - - if: steps.packagejson.outputs.exists == 'true' - name: Install dependencies - run: npm ci - - if: steps.packagejson.outputs.exists == 'true' - name: Assets generation - run: npm run generate:assets --if-present - - if: steps.packagejson.outputs.exists == 'true' - name: Bump version in package.json - # There is no need to substract "v" from the tag as version script handles it - # When adding "bump:version" script in package.json, make sure no tags are added by default (--no-git-tag-version) as they are already added by release workflow - # When adding "bump:version" script in package.json, make sure --allow-same-version is set in case someone forgot and updated package.json manually and we want to avoide this action to fail and raise confusion - run: VERSION=${{github.event.release.tag_name}} npm run bump:version - - if: steps.packagejson.outputs.exists == 'true' - name: Create Pull Request with updated asset files including package.json - uses: peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54 # use 4.2.4 https://github.com/peter-evans/create-pull-request/releases/tag/v4.2.4 - with: - token: ${{ secrets.GH_TOKEN }} - commit-message: 'chore(release): ${{github.event.release.tag_name}}' - committer: asyncapi-bot - author: asyncapi-bot - title: 'chore(release): ${{github.event.release.tag_name}}' - body: 'Version bump in package.json for release [${{github.event.release.tag_name}}](${{github.event.release.html_url}})' - branch: version-bump/${{github.event.release.tag_name}} - - if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel - name: Report workflow run status to Slack - uses: 8398a7/action-slack@v3 - with: - status: ${{ job.status }} - fields: repo,action,workflow - text: 'Unable to bump the version in package.json after the release' - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} \ No newline at end of file diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml index 21790e4bfb8..1bfd870ceaa 100644 --- a/.github/workflows/release-docker.yml +++ b/.github/workflows/release-docker.yml @@ -5,7 +5,6 @@ on: - published jobs: - publish-docker: name: Generating Docker runs-on: ubuntu-latest @@ -17,6 +16,11 @@ jobs: VERSION_WITHOUT_V=${VERSION:1} echo "value=${VERSION_WITHOUT_V}" >> $GITHUB_OUTPUT + - name : Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.tag_name }} + - name: Set Up QEMU uses: docker/setup-qemu-action@v2 @@ -29,10 +33,6 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - # This workflow triggers on GitHub Release, but it may start before the npm package is published. - - name: Sleep for 30 sec - run: sleep 30s - - name: Build Image uses: docker/build-push-action@v4 with: @@ -56,3 +56,45 @@ jobs: pass: ${{ secrets.DOCKER_PASSWORD }} slug: asyncapi/cli description: CLI to work with your AsyncAPI files + + publish-action-docker: + name: Release github action for cli and update version in action.yml + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: master + + - name: Get version without v character + id: version + run: | + VERSION=${{github.event.release.tag_name}} + VERSION_WITHOUT_V=${VERSION:1} + echo "value=${VERSION_WITHOUT_V}" >> $GITHUB_OUTPUT + + - name: Release to Docker + run: | + echo ${{env.DOCKER_PASSWORD}} | docker login -u ${{env.DOCKER_USERNAME}} --password-stdin + npm run action:docker:build + docker tag asyncapi/github-action-for-cli:latest asyncapi/github-action-for-cli:${{ steps.version.outputs.value }} + docker push asyncapi/github-action-for-cli:${{ steps.version.outputs.value }} + docker push asyncapi/github-action-for-cli:latest + + - name: Change directory to github-action + run: | + cd github-action/ + ls -la + + - uses: meeDamian/sync-readme@v1.0.6 + with: + user: ${{ env.DOCKER_USERNAME }} + pass: ${{ env.DOCKER_PASSWORD }} + slug: asyncapi/github-action-for-cli + description: Github action for AsyncAPI CLI + diff --git a/.github/workflows/if-nodejs-release.yml b/.github/workflows/release-with-changesets.yml similarity index 69% rename from .github/workflows/if-nodejs-release.yml rename to .github/workflows/release-with-changesets.yml index 72d01de477a..a05e09c79da 100644 --- a/.github/workflows/if-nodejs-release.yml +++ b/.github/workflows/release-with-changesets.yml @@ -1,15 +1,11 @@ -# This action is centrally managed in https://github.com/asyncapi/.github/ -# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo - -# It does magic only if there is package.json file in the root of the project -name: Release - if Node project +# It does magic only if there is a package.json file in the root of the project +name: Release on: push: branches: - master - # below lines are not enough to have release supported for these branches - # make sure configuration of `semantic-release` package mentions these branches + # The below lines are not enough to have release supported for these branches - next-spec - next-major - next-major-spec @@ -18,26 +14,26 @@ on: - next jobs: - test-nodejs: - # We just check the message of first commit as there is always just one commit because we squash into one before merging - # "commits" contains array of objects where one of the properties is commit "message" + # We just check the message of the first commit as there is always just one commit because we squash into one before merging + # "commits" contains an array of objects where one of the properties is the commit "message" # Release workflow will be skipped if release conventional commits are not used if: | - startsWith( github.repository, 'asyncapi/' ) && + startsWith( github.repository, 'asyncapi/' ) && (startsWith( github.event.commits[0].message , 'fix:' ) || startsWith( github.event.commits[0].message, 'fix!:' ) || startsWith( github.event.commits[0].message, 'feat:' ) || + startsWith( github.event.commits[0].message, 'chore(release):' ) || startsWith( github.event.commits[0].message, 'feat!:' )) name: Test NodeJS release on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: - # Using macos-13 instead of latest (macos-14) due to an issue with Puppeteer and such runner. + # Using macos-13 instead of latest (macos-14) due to an issue with Puppeteer and such runner. # See: https://github.com/puppeteer/puppeteer/issues/12327 and https://github.com/asyncapi/parser-js/issues/1001 os: [ubuntu-latest, macos-13, windows-latest] steps: - - name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows + - name: Set git to use LF # To once and for all finish the never-ending fight between Unix and Windows run: | git config --global core.autocrlf false git config --global core.eol lf @@ -60,7 +56,7 @@ jobs: - if: steps.lockversion.outputs.version == '18' && matrix.os == 'windows-latest' name: Install npm cli 8 shell: bash - #npm cli 10 is buggy because of some cache issues + # npm cli 10 is buggy because of some cache issues run: npm install -g npm@8.19.4 - if: steps.packagejson.outputs.exists == 'true' name: Install dependencies @@ -75,16 +71,16 @@ jobs: with: status: ${{ job.status }} fields: repo,action,workflow - text: 'Release workflow failed in testing job' + text: "Release workflow failed in testing job" env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} release: needs: [test-nodejs] - name: Publish to any of NPM, Github, or Docker Hub + name: Publish to any of NPM, GitHub, or Docker Hub runs-on: ubuntu-latest steps: - - name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows + - name: Set git to use LF # To once and for all finish the never-ending fight between Unix and Windows run: | git config --global core.autocrlf false git config --global core.eol lf @@ -108,27 +104,35 @@ jobs: shell: bash run: npm ci - if: steps.packagejson.outputs.exists == 'true' - name: Add plugin for conventional commits for semantic-release - run: npm install --save-dev conventional-changelog-conventionalcommits@5.0.0 + name: Install changelog + shell: bash + # This step can be removed once the issue is fixed in the changeset package. + run: npm install @changesets/changelog-git@0.2.0 + - if: steps.packagejson.outputs.exists == 'true' name: Publish to any of NPM, Github, and Docker Hub + #this step has 2 goals, it is either identifying that there is changeset file created and then this action creates a PR with version bump that will trigger release - or if it sees there is no changeset, and there are versions changes in package.json files, it publish new versions to NPM is they are not there yet + uses: changesets/action@v1 id: release + with: + version: npm run bump:version + commit: "chore(release): release and bump versions of packages" + title: "chore(release): release and bump versions of packages" + publish: npx -p @changesets/cli@2.27.7 changeset publish + setupGitUser: false env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} GIT_AUTHOR_NAME: asyncapi-bot GIT_AUTHOR_EMAIL: info@asyncapi.io GIT_COMMITTER_NAME: asyncapi-bot GIT_COMMITTER_EMAIL: info@asyncapi.io - run: npx semantic-release@19.0.4 - - if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel + - if: failure() # Only, on failure, send a message on the 94_bot-failing-ci Slack channel name: Report workflow run status to Slack uses: 8398a7/action-slack@v3 with: status: ${{ job.status }} fields: repo,action,workflow - text: 'Release workflow failed in release job' + text: "Release workflow failed in release job" env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} diff --git a/.github/workflows/scripts/mailchimp/package-lock.json b/.github/workflows/scripts/mailchimp/package-lock.json index 4510570ec17..7ee7d84f86f 100644 --- a/.github/workflows/scripts/mailchimp/package-lock.json +++ b/.github/workflows/scripts/mailchimp/package-lock.json @@ -7,34 +7,24 @@ "name": "schedule-email", "license": "Apache 2.0", "dependencies": { - "@actions/core": "1.9.1", + "@actions/core": "1.6.0", "@mailchimp/mailchimp_marketing": "3.0.74" } }, "node_modules/@actions/core": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz", - "integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz", + "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==", "dependencies": { - "@actions/http-client": "^2.0.1", - "uuid": "^8.3.2" + "@actions/http-client": "^1.0.11" } }, "node_modules/@actions/http-client": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.1.tgz", - "integrity": "sha512-KhC/cZsq7f8I4LfZSJKgCvEwfkE8o1538VoBeoGzokVLLnbFDEAdFD3UhoMklxo2un9NJVBdANOresx7vTHlHw==", + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", + "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", "dependencies": { - "tunnel": "^0.0.6", - "undici": "^5.25.4" - } - }, - "node_modules/@fastify/busboy": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz", - "integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==", - "engines": { - "node": ">=14" + "tunnel": "0.0.6" } }, "node_modules/@mailchimp/mailchimp_marketing": { @@ -83,9 +73,9 @@ "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==" }, "node_modules/cookiejar": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", - "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==" + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", + "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==" }, "node_modules/core-util-is": { "version": "1.0.3", @@ -337,55 +327,29 @@ "node": ">=0.6.11 <=0.7.0 || >=0.7.3" } }, - "node_modules/undici": { - "version": "5.28.4", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz", - "integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==", - "dependencies": { - "@fastify/busboy": "^2.0.0" - }, - "engines": { - "node": ">=14.0" - } - }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" - }, - "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "bin": { - "uuid": "dist/bin/uuid" - } } }, "dependencies": { "@actions/core": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz", - "integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz", + "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==", "requires": { - "@actions/http-client": "^2.0.1", - "uuid": "^8.3.2" + "@actions/http-client": "^1.0.11" } }, "@actions/http-client": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.1.tgz", - "integrity": "sha512-KhC/cZsq7f8I4LfZSJKgCvEwfkE8o1538VoBeoGzokVLLnbFDEAdFD3UhoMklxo2un9NJVBdANOresx7vTHlHw==", + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", + "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", "requires": { - "tunnel": "^0.0.6", - "undici": "^5.25.4" + "tunnel": "0.0.6" } }, - "@fastify/busboy": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz", - "integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==" - }, "@mailchimp/mailchimp_marketing": { "version": "3.0.74", "resolved": "https://registry.npmjs.org/@mailchimp/mailchimp_marketing/-/mailchimp_marketing-3.0.74.tgz", @@ -423,9 +387,9 @@ "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==" }, "cookiejar": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", - "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==" + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", + "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==" }, "core-util-is": { "version": "1.0.3", @@ -624,23 +588,10 @@ "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" }, - "undici": { - "version": "5.28.4", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz", - "integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==", - "requires": { - "@fastify/busboy": "^2.0.0" - } - }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" - }, - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" } } -} +} \ No newline at end of file diff --git a/.github/workflows/scripts/mailchimp/package.json b/.github/workflows/scripts/mailchimp/package.json index 28b447ff7ce..cc50e43e029 100644 --- a/.github/workflows/scripts/mailchimp/package.json +++ b/.github/workflows/scripts/mailchimp/package.json @@ -3,7 +3,7 @@ "description": "This code is responsible for scheduling an email campaign. This file is centrally managed in https://github.com/asyncapi/.github/", "license": "Apache 2.0", "dependencies": { - "@actions/core": "1.9.1", + "@actions/core": "1.6.0", "@mailchimp/mailchimp_marketing": "3.0.74" } } \ No newline at end of file diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml new file mode 100644 index 00000000000..3b6a1ed0038 --- /dev/null +++ b/.github/workflows/test-action.yml @@ -0,0 +1,345 @@ +name: PR testing of CLI action + +on: + pull_request: + types: [ opened, synchronize, reopened, ready_for_review ] + +jobs: + should-workflow-run: + runs-on: ubuntu-latest + steps: + - if: > + !github.event.pull_request.draft && !( + (github.actor == 'asyncapi-bot' && ( + startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') || + startsWith(github.event.pull_request.title, 'chore(release):') + )) || + (github.actor == 'asyncapi-bot-eve' && ( + startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') || + startsWith(github.event.pull_request.title, 'chore(release):') + )) || + (github.actor == 'allcontributors[bot]' && + startsWith(github.event.pull_request.title, 'docs: add') + ) + ) + id: should_run + name: Should Run + run: echo "shouldrun=true" >> $GITHUB_OUTPUT + outputs: + shouldrun: ${{ steps.should_run.outputs.shouldrun }} + + build-docker: + needs: should-workflow-run + name: Build Docker image + if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Get docker version + id: docker_version + run: > + ls -la; + action=$(cat action.yml); + regex='docker:\/\/asyncapi\/github-action-for-cli:([0-9.]+)'; + [[ $action =~ $regex ]]; + action_version=${BASH_REMATCH[1]}; + echo "action_version=$action_version" >> $GITHUB_OUTPUT + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build Docker image and export + uses: docker/build-push-action@v5 + with: + context: . + file: ./github-action/Dockerfile + tags: asyncapi/github-action-for-cli:${{ steps.docker_version.outputs.action_version }} + outputs: type=docker,dest=/tmp/asyncapi.tar + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: asyncapi + path: /tmp/asyncapi.tar + + + test-defaults: + if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }} + runs-on: ubuntu-latest + needs: [should-workflow-run, build-docker] + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: asyncapi + path: /tmp + - name: Load Docker image + run: | + docker load --input /tmp/asyncapi.tar + docker image ls -a + - uses: actions/checkout@v4 + - name: Test GitHub Action + uses: ./ + with: + filepath: ./github-action/test/asyncapi.yml + - name: Assert GitHub Action + run: | + echo "Listing all files" + ls -R + echo "Asserting GitHub Action" + if [ -f "./output/asyncapi.md" ]; then + echo "Files exist" + else + echo "Files do not exist:- ./output/asyncapi.md" + echo "Action failed" + exit 1 + fi + + test-validate-success: + if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }} + runs-on: ubuntu-latest + needs: [should-workflow-run, build-docker] + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: asyncapi + path: /tmp + - name: Load Docker image + run: | + docker load --input /tmp/asyncapi.tar + docker image ls -a + - uses: actions/checkout@v4 + - name: Test GitHub Action + uses: ./ + with: + filepath: ./github-action/test/asyncapi.yml + command: validate + + test-custom-command: + if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }} + runs-on: ubuntu-latest + needs: [should-workflow-run, build-docker] + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: asyncapi + path: /tmp + - name: Load Docker image + run: | + docker load --input /tmp/asyncapi.tar + docker image ls -a + - uses: actions/checkout@v4 + - name: Test GitHub Action + uses: ./ + with: + # Custom command to generate models + # Note: You can use command itself to generate models, but this is just an example for testing custom commands + custom_command: "generate models typescript ./github-action/test/asyncapi.yml -o ./output" + - name: Assert GitHub Action + run: | + echo "Listing all files" + ls -R + echo "Asserting GitHub Action" + if [ -f "./output/AnonymousSchema_1.ts" ]; then + echo "Models have been generated" + else + echo "Models have not been generated" + echo "Action failed" + exit 1 + fi + + test-custom-output: + if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }} + runs-on: ubuntu-latest + needs: [should-workflow-run, build-docker] + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: asyncapi + path: /tmp + - name: Load Docker image + run: | + docker load --input /tmp/asyncapi.tar + docker image ls -a + - uses: actions/checkout@v4 + - name: Test GitHub Action + uses: ./ + with: + filepath: ./github-action/test/asyncapi.yml + output: custom-output + - name: Assert GitHub Action + run: | + echo "Listing all files" + ls -R + echo "Asserting GitHub Action" + if [ -f "./custom-output/asyncapi.md" ]; then + echo "Files exist" + else + echo "Files do not exist:- ./custom-output/asyncapi.md" + echo "Action failed" + exit 1 + fi + + test-file-not-found: + if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }} + runs-on: ubuntu-latest + needs: [should-workflow-run, build-docker] + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: asyncapi + path: /tmp + - name: Load Docker image + run: | + docker load --input /tmp/asyncapi.tar + docker image ls -a + - uses: actions/checkout@v4 + - name: Test GitHub Action + id: test + uses: ./ + with: + filepath: non_existent_file.yml + continue-on-error: true + - name: Check for failure + run: | + if [ "${{ steps.test.outcome }}" == "success" ]; then + echo "Test Failure: non_existent_file.yml should throw an error but did not" + exit 1 + else + echo "Test Success: non_existent_file.yml threw an error as expected" + fi + + test-invalid-input: + if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }} + runs-on: ubuntu-latest + needs: [should-workflow-run, build-docker] + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: asyncapi + path: /tmp + - name: Load Docker image + run: | + docker load --input /tmp/asyncapi.tar + docker image ls -a + - uses: actions/checkout@v4 + - name: Test GitHub Action + id: test + uses: ./ + with: + filepath: github-action/test/asyncapi.yml + command: generate # No template or language specified + template: '' # Empty string + continue-on-error: true + - name: Check for failure + run: | + if [ "${{ steps.test.outcome }}" == "success" ]; then + echo "Test Failure: generate command should throw an error as no template or language specified but did not" + exit 1 + else + echo "Test Success: generate command threw an error as expected" + fi + + test-optimize: + if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }} + runs-on: ubuntu-latest + needs: [should-workflow-run, build-docker] + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: asyncapi + path: /tmp + - name: Load Docker image + run: | + docker load --input /tmp/asyncapi.tar + docker image ls -a + - uses: actions/checkout@v4 + - name: Test GitHub Action + uses: ./ + with: + filepath: github-action/test/unoptimized.yml + command: optimize + parameters: '-o new-file --no-tty' + - name: Assert GitHub Action + run: | + echo "Listing all files" + ls -R + echo "Asserting GitHub Action" + if [ -f "./github-action/test/unoptimized_optimized.yml" ]; then + echo "The specified file has been optimized" + else + echo "The specified file has not been optimized" + echo "Action failed" + exit 1 + fi + + test-bundle: + if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }} + runs-on: ubuntu-latest + needs: [should-workflow-run, build-docker] + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: asyncapi + path: /tmp + - name: Load Docker image + run: | + docker load --input /tmp/asyncapi.tar + docker image ls -a + - uses: actions/checkout@v4 + - name: Make output directory + run: mkdir -p ./output/bundle + - name: Test GitHub Action + uses: ./ + with: + custom_command: 'bundle ./github-action/test/bundle/asyncapi.yaml ./github-action/test/bundle/features.yaml --base ./github-action/test/bundle/asyncapi.yaml -o ./output/bundle/asyncapi.yaml' + - name: Assert GitHub Action + run: | + echo "Listing all files" + ls -R + echo "Asserting GitHub Action" + if [ -f "./output/bundle/asyncapi.yaml" ]; then + echo "The specified files have been bundled" + else + echo "The specified files have not been bundled" + echo "Action failed" + exit 1 + fi + + test-convert: + if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }} + runs-on: ubuntu-latest + needs: [should-workflow-run, build-docker] + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: asyncapi + path: /tmp + - name: Load Docker image + run: | + docker load --input /tmp/asyncapi.tar + docker image ls -a + - uses: actions/checkout@v4 + - name: Test GitHub Action + uses: ./ + with: + command: convert + filepath: github-action/test/asyncapi.yml + output: output/convert/asyncapi.yaml + - name: Assert GitHub Action + run: | + echo "Listing all files" + ls -R + echo "Asserting GitHub Action" + if [ -f "./output/convert/asyncapi.yaml" ]; then + echo "The specified file has been converted" + else + echo "The specified file has not been converted" + echo "Action failed" + exit 1 + fi diff --git a/.github/workflows/update-maintainers-trigger.yaml b/.github/workflows/update-maintainers-trigger.yaml new file mode 100644 index 00000000000..12fc4abe4f0 --- /dev/null +++ b/.github/workflows/update-maintainers-trigger.yaml @@ -0,0 +1,28 @@ +# This action is centrally managed in https://github.com/asyncapi/.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo + +name: Trigger MAINTAINERS.yaml file update + +on: + push: + branches: [ master ] + paths: + # Check all valid CODEOWNERS locations: + # https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-file-location + - 'CODEOWNERS' + - '.github/CODEOWNERS' + - '.docs/CODEOWNERS' + +jobs: + trigger-maintainers-update: + name: Trigger updating MAINTAINERS.yaml because of CODEOWNERS change + runs-on: ubuntu-latest + + steps: + - name: Repository Dispatch + uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # https://github.com/peter-evans/repository-dispatch/releases/tag/v3.0.0 + with: + # The PAT with the 'public_repo' scope is required + token: ${{ secrets.GH_TOKEN }} + repository: ${{ github.repository_owner }}/community + event-type: trigger-maintainers-update diff --git a/.github/workflows/upload-release-assets.yml b/.github/workflows/upload-release-assets.yml index e0018e4b0b9..b56e0eb6689 100644 --- a/.github/workflows/upload-release-assets.yml +++ b/.github/workflows/upload-release-assets.yml @@ -1,16 +1,13 @@ name: Upload custom assets to GitHub release on: - # It cannot run on release event as when release is created then version is not yet bumped in package.json - # This means we cannot extract easily latest version and have a risk that package is not yet on npm - push: - branches: - - master + release: + types: + - published jobs: upload-assets: name: Generate and upload assets - if: startsWith(github.event.commits[0].message, 'chore(release):') runs-on: ${{ matrix.os }} continue-on-error: true strategy: @@ -50,6 +47,11 @@ jobs: uses: actions/setup-node@v4 with: node-version: "${{ steps.lockversion.outputs.version }}" + - if: matrix.npm_script == 'pack:windows' + name: install nodejs for windows + uses: actions/setup-node@v4 + with: + node-version: 20 - name: Get version from package.json uses: actions/github-script@v6 id: extractver @@ -62,11 +64,12 @@ jobs: #fix for windows build issue #1433 name: Install p7zip-full nsis run: sudo apt-get install -y p7zip-full nsis - - if: steps.lockversion.outputs.version == '18' && matrix.os == 'windows-latest' + + - if: matrix.npm_script == 'pack:windows' #npm cli 10 is buggy because of some cache issue - name: Install npm cli 8 + name: Install npm cli 10 shell: bash - run: npm install -g npm@8.19.4 + run: npm install -g npm@latest - name: Install dependencies run: npm ci - name: Build project diff --git a/.gitignore b/.gitignore index b50ab0c5d88..d9a57e16e83 100644 --- a/.gitignore +++ b/.gitignore @@ -16,10 +16,15 @@ node_modules /test/integration/generate/models/ test.asyncapi-cli asyncapi.json -asyncapi.yml test/fixtures/minimaltemplate/__transpiled +test/fixtures/specification-conv.yml +test/fixtures/specification-conv.yaml +test/fixtures/specification-conv.json .vscode +/action/ +/github-action/output/ + oclif.manifest.json spec-examples.zip 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/.releaserc b/.releaserc deleted file mode 100644 index 1ac05cb151a..00000000000 --- a/.releaserc +++ /dev/null @@ -1,24 +0,0 @@ ---- -branches: -- master -# by default release workflow reacts on push not only to master. -#This is why out of the box sematic release is configured for all these branches -- name: next-spec - prerelease: true -- name: next-major - prerelease: true -- name: next-major-spec - prerelease: true -- name: beta - prerelease: true -- name: alpha - prerelease: true -- name: next - prerelease: true -plugins: -- - "@semantic-release/commit-analyzer" - - preset: conventionalcommits -- - "@semantic-release/release-notes-generator" - - preset: conventionalcommits -- "@semantic-release/npm" -- "@semantic-release/github" diff --git a/.sonarcloud.properties b/.sonarcloud.properties index 0657ce6336b..c3855a2d181 100644 --- a/.sonarcloud.properties +++ b/.sonarcloud.properties @@ -1 +1,9 @@ -sonar.exclusions=test/**/* \ No newline at end of file +sonar.exclusions=test/**/*,Dockerfile,github-action/Dockerfile +sonar.issue.ignore.multicriteria=e1,e2 + +# Exclude copy recursively and root user issue in Dockerfile +sonar.issue.ignore.multicriteria.e1.ruleKey=docker:S6470 +sonar.issue.ignore.multicriteria.e1.resourceKey=**/Dockerfile + +sonar.issue.ignore.multicriteria.e2.ruleKey=docker:S6471 +sonar.issue.ignore.multicriteria.e2.resourceKey=**/Dockerfile diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000000..4b456efc8c2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,38 @@ +# @asyncapi/cli + +## 2.15.0 + +### Minor Changes + +- dcfb8c7: fix: Remove unused package lodash.template + +## 2.14.1 + +### Patch Changes + +- 08afb45: Prepare github action for release +- da64c63: ci: bump artifact actions to v4 + +## 2.14.0 + +### Minor Changes + +- 6839c8f: - Changed docker build to a source code based build + - Changed name of github action to avoid clash + - Fixed Docker and Release Pipeline + +## 2.13.1 + +### Patch Changes + +- 8ae33c4: Handle AsyncAPI v3 in diff command + +## 2.13.0 + +### Minor Changes + +- a76b0fb: Add github-action to monorepo and set up changesets + +### Patch Changes + +- 81b925e: Updated README with Development.md file diff --git a/CODEOWNERS b/CODEOWNERS index be2f15a7bb7..fff90b1d685 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -5,4 +5,4 @@ # For more details, read the following article on GitHub: https://help.github.com/articles/about-codeowners/. # The default owners are automatically added as reviewers when you open a pull request unless different owners are specified in the file. -* @Souvikns @Amzani @Shurtu-gal @asyncapi-bot-eve +* @Souvikns @Amzani @Shurtu-gal @asyncapi-bot-eve @AayushSaini101 diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 00000000000..da228de676c --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,141 @@ +# Development guide + +This guide will help you set up the `cli` locally, run tests, and use Docker for isolated testing. + +## Getting started + +1. Fork & Clone the repository: + +First fork the repository from github and then clone it, + +```bash +git clone https://github.com/{your_username}/cli.git +cd cli +``` + +After cloning the repository, you should setup the fork properly and configure the `remote` repository as described [here](https://github.com/asyncapi/community/blob/master/git-workflow.md) + +2. Install dependencies: + +```bash +npm install +``` + +## Running tests + +### Local testing + +To run all tests locally: + +- Unit tests: `npm run test:unit` +- Github action tests: `npm run action:test` + +### Adding tests + +1. Create new test files in the appropriate directory under `test/`: + +2. Follow the existing test patterns. + +3. Run your new tests using the commands mentioned above. + +## Release process + +To release a major/minor/patch: + +### Conventional Commits: + +To maintain a clear git history of commits and easily identify what each commit changed and whether it triggered a release, we use conventional commits. The feat and fix prefixes are particularly important as they are needed to trigger changesets. Using these prefixes ensures that the changes are correctly categorized and the versioning system functions as expected. + +For Example: +``` +feat: add new feature +``` + +#### Manual + +1. Create a new release markdown file in the `.changeset` directory. The filename should indicate what the change is about. + +2. Add the following content to the file in this particular format: + + ```markdown + --- + "@package-name-1": [type] (major/minor/patch) + "@package-name-2": [type] + --- + + [Provide a brief description of the changes. For example: Added a new Release GitHub Flow to the Turborepo. No new features or bugfixes were introduced.] + ``` + + For Example: + + ```markdown + --- + "@asyncapi/cli": minor + --- + + Adding new Release Github Flow to the Turborepo. No new features or bugfixes were introduced. + + ``` + +3. Include the file in your pull request. + +#### Using CLI + +1. Create a new release markdown file using changeset CLI. Below command will trigger an interactive prompt that you can use to specify release type and affected packages. + ```cli + npx -p @changesets/cli@2.27.7 changeset + ``` + +2. Include the file in your pull request. + +> [!TIP] +> For more detailed instructions, you can refer to the official documentation for creating a changeset: +[Adding a changeset](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md) + +### Release Flow: + +1. **Add a Changeset**: + - When you make changes that need to be released, create a markdown file in the `.changeset` directory stating the package name and level of change (major/minor/patch). + +2. **Open a Pull Request**: + - Push your changes and open a Pull Request (PR). After the PR is merged the changeset file helps communicate the type of changes (major, minor, patch). + +3. **CI Processes Changeset**: + - After PR is merged, a dedicated GitHub Actions release workflow runs using changeset action, + + - This action reads the markdown files in the `.changeset` folder and creates a PR with the updated version of the package and removes the markdown file. For example: + + Before: + ```json + "name": "@asyncapi/cli", + "version": "2.0.1", + ``` + + After: + ```json + "name": "@asyncapi/cli", + "version": "3.0.1", + ``` + + - The new PR will also contain the description from the markdown files, + + - AsyncAPI bot automatically merge such release PR. + +4. **Release the Package**: + + - After the PR is merged, the CI/CD pipeline triggers again. The `changesets/action` step identifies that the PR was created by itself. It then verifies if the current version of the package is greater than the previously released version. If a difference is detected, it executes the publish command to release the updated package. + +## Additional commands + +- Lint the code: `npm run lint` +- Build Docker image: `npm run docker:build` + +## Troubleshooting + +If you encounter any issues during development or testing, please check the following: + +1. Ensure you're using the correct Node.js version (18.12.0 or higher) and npm version (8.19.0 or higher). +2. Clear the `node_modules` directory and reinstall dependencies if you encounter unexpected behavior. +3. For Docker-related issues, make sure Docker is running and you have sufficient permissions. + +If problems persist, please open an issue on the GitHub repository. diff --git a/Dockerfile b/Dockerfile index c2d7945239f..bee568fe55f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,30 @@ +FROM node:20-alpine AS build + +# Copy the source code +COPY ./ /tmp/source_code + +# Install dependencies +RUN cd /tmp/source_code && npm install --ignore-scripts + +# Build the source code +RUN cd /tmp/source_code && npm run build + +# create libraries directory +RUN mkdir -p /libraries + +# Copy the lib, bin, node_modules, and package.json files to the /libraries directory +RUN cp -r /tmp/source_code/lib /libraries +RUN cp -r /tmp/source_code/assets /libraries +RUN cp /tmp/source_code/package.json /libraries +RUN cp /tmp/source_code/package-lock.json /libraries +RUN cp /tmp/source_code/oclif.manifest.json /libraries + +# Copy the bin directory to the /libraries directory +RUN cp -r /tmp/source_code/bin /libraries + +# Remove everything inside /tmp +RUN rm -rf /tmp/* + FROM node:20-alpine # Set ARG to explicit value to build chosen version. Default is "latest" @@ -19,8 +46,20 @@ RUN apk --update add git chromium && \ rm -rf /var/lib/apt/lists/* && \ rm /var/cache/apk/* -# Installing latest released npm package -RUN npm install --ignore-scripts -g @asyncapi/cli@"$ASYNCAPI_CLI_VERSION" +# Copy the libraries directory from the build stage +COPY --from=build /libraries /libraries + +# Install the dependencies +RUN cd /libraries && npm install --production --ignore-scripts + +# Create a script that runs the desired command +RUN ln -s /libraries/bin/run_bin /usr/local/bin/asyncapi + +# Make the script executable +RUN chmod +x /usr/local/bin/asyncapi + +# Change ownership to non-root user +RUN chown -R myuser:myuser /libraries /usr/local/bin/asyncapi || echo "Failed to change ownership" RUN chown -R myuser:myuser /usr/local/lib/node_modules && \ chown -R myuser:myuser /usr/local/bin diff --git a/README.md b/README.md index dee51d2c65e..15d0f6e9005 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,10 @@ Read [CONTRIBUTING](https://github.com/asyncapi/.github/blob/master/CONTRIBUTING ### Set up development environment -Follow these steps: +Read [DEVELOPMENT.md](/DEVELOPMENT.md) file for development setup. + +Additional steps: -- Clone the repo. -- Run `npm install` to install all the required dependencies - Run `npm run test` to make sure everything is properly set up - Run `npm run build` and then `bin/run` to try new CLI locally diff --git a/action-template.yml b/action-template.yml new file mode 100644 index 00000000000..40aba410cbb --- /dev/null +++ b/action-template.yml @@ -0,0 +1,54 @@ +name: 'Generator, Validator, Converter and others - all in one for your AsyncAPI docs' +description: 'Use this action to generate docs or code from your AsyncAPI document. Use default templates or provide your custom ones.' +inputs: + cli_version: + description: 'Version of AsyncAPI CLI to be used. This is only needed if you want to test with a specific version of AsyncAPI CLI. Default is latest which is also the recommended option.' + required: false + default: '' + command: + description: 'Command to run. Available commands in action :- generate, validate, convert, optimize and custom. Default is generate. For custom command, provide the whole command as input. List of available commands can be found in https://www.asyncapi.com/docs/tools/cli/usage.' + required: false + default: 'generate' + filepath: + description: 'Path to AsyncAPI document. This input is required if command is set to generate, validate, convert or optimize. Default is ./asyncapi.yaml' + required: false + default: 'asyncapi.yml' + template: + description: 'Template for the generator. Official templates are listed here https://github.com/search?q=topic%3Aasyncapi+topic%3Agenerator+topic%3Atemplate. You can pass template as npm package, url to git repository, link to tar file or local template.' + default: '@asyncapi/markdown-template@0.10.0' + required: false + language: + description: 'Language of the generated code. This input is required if you want to generate models. List of available languages can be found in https://www.asyncapi.com/docs/tools/cli/usage#asyncapi-generate-models-language-file' + required: false + default: '' + output: + description: 'Directory where to put the generated files. Can be used only with generate or convert commands. Default is output.' + required: false + default: 'output' + parameters: + description: 'The command that you use might support and even require specific parameters to be passed to the CLI for the generation. Template parameters should be preceded by -p' + required: false + default: '' + custom_command: + description: 'Custom command to be run. This input is required if command is set to custom.' + required: false + default: '' + +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:${ version }' + args: + - ${{ inputs.cli_version }} + - ${{ inputs.command }} + - ${{ inputs.filepath }} + - ${{ inputs.template }} + - ${{ inputs.language }} + - ${{ inputs.output }} + - ${{ inputs.parameters }} + - ${{ inputs.custom_command }} + +branding: + icon: 'file-text' + color: purple diff --git a/action.yml b/action.yml new file mode 100644 index 00000000000..4af9aeb1dd8 --- /dev/null +++ b/action.yml @@ -0,0 +1,54 @@ +name: 'Generator, Validator, Converter and others - all in one for your AsyncAPI docs' +description: 'Use this action to generate docs or code from your AsyncAPI document. Use default templates or provide your custom ones.' +inputs: + cli_version: + description: 'Version of AsyncAPI CLI to be used. This is only needed if you want to test with a specific version of AsyncAPI CLI. Default is latest which is also the recommended option.' + required: false + default: '' + command: + description: 'Command to run. Available commands in action :- generate, validate, convert, optimize and custom. Default is generate. For custom command, provide the whole command as input. List of available commands can be found in https://www.asyncapi.com/docs/tools/cli/usage.' + required: false + default: 'generate' + filepath: + description: 'Path to AsyncAPI document. This input is required if command is set to generate, validate, convert or optimize. Default is ./asyncapi.yaml' + required: false + default: 'asyncapi.yml' + template: + description: 'Template for the generator. Official templates are listed here https://github.com/search?q=topic%3Aasyncapi+topic%3Agenerator+topic%3Atemplate. You can pass template as npm package, url to git repository, link to tar file or local template.' + default: '@asyncapi/markdown-template@0.10.0' + required: false + language: + description: 'Language of the generated code. This input is required if you want to generate models. List of available languages can be found in https://www.asyncapi.com/docs/tools/cli/usage#asyncapi-generate-models-language-file' + required: false + default: '' + output: + description: 'Directory where to put the generated files. Can be used only with generate or convert commands. Default is output.' + required: false + default: 'output' + parameters: + description: 'The command that you use might support and even require specific parameters to be passed to the CLI for the generation. Template parameters should be preceded by -p' + required: false + default: '' + custom_command: + description: 'Custom command to be run. This input is required if command is set to custom.' + required: false + default: '' + +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.15.0' + args: + - ${{ inputs.cli_version }} + - ${{ inputs.command }} + - ${{ inputs.filepath }} + - ${{ inputs.template }} + - ${{ inputs.language }} + - ${{ inputs.output }} + - ${{ inputs.parameters }} + - ${{ inputs.custom_command }} + +branding: + icon: 'file-text' + color: purple diff --git a/assets/create-glee-app/templates/default/package-lock.json b/assets/create-glee-app/templates/default/package-lock.json index af1796b3eab..bf3add4fa91 100644 --- a/assets/create-glee-app/templates/default/package-lock.json +++ b/assets/create-glee-app/templates/default/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.0", "license": "Apache-2.0", "dependencies": { - "@asyncapi/glee": "^0.37.8" + "@asyncapi/glee": "^0.37.9" }, "devDependencies": { "@types/node": "^20.5.9" @@ -169,12 +169,12 @@ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" }, "node_modules/@asyncapi/glee": { - "version": "0.37.8", - "resolved": "https://registry.npmjs.org/@asyncapi/glee/-/glee-0.37.8.tgz", - "integrity": "sha512-1qa/OuOzA38AvuNu1w/wduXKnXjxtHMcCYggVoCQVIzJZ6lG9xaK73g3floUUDK5sMAqiytvisCyGVobXzv4Kw==", + "version": "0.37.9", + "resolved": "https://registry.npmjs.org/@asyncapi/glee/-/glee-0.37.9.tgz", + "integrity": "sha512-mruRd34RpE+0VoQ5jKA67a4d8qyJzTY42p6qGj0O7gpL2UB1tus8eP/cbapbyE0DB3LeMDhIu4m04yfYOlw6Gw==", "dependencies": { "@asyncapi/generator": "^1.17.25", - "@asyncapi/html-template": "^2.3.14", + "@asyncapi/html-template": "^3.0.0", "@asyncapi/markdown-template": "^1.6.6", "@asyncapi/parser": "^3.1.0", "@next/env": "^14.0.4", @@ -216,9 +216,9 @@ } }, "node_modules/@asyncapi/html-template": { - "version": "2.3.14", - "resolved": "https://registry.npmjs.org/@asyncapi/html-template/-/html-template-2.3.14.tgz", - "integrity": "sha512-e7jHGXNtovA2u9n0A9CtPy+xkXa76vpz+gdY/4q4TC4bm6EadEhcDiNQ0LtFnUjcHDuxXzYZs8/0BZr1vSBeQw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@asyncapi/html-template/-/html-template-3.0.0.tgz", + "integrity": "sha512-U5+fx9fdtQwi7C6PabODP01m1z596fhOjCcRdaOHI2/OBm2DFeQIDel2QZ1B1KmChouANaj0IC4lGfJgJcPw1g==", "dependencies": { "@asyncapi/generator-react-sdk": "^1.1.2", "@asyncapi/parser": "^3.1.0", @@ -5369,9 +5369,9 @@ "peer": true }, "node_modules/cookie": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", - "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", "engines": { "node": ">= 0.6" } @@ -5462,9 +5462,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.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -5846,9 +5846,9 @@ } }, "node_modules/dompurify": { - "version": "2.5.6", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.5.6.tgz", - "integrity": "sha512-zUTaUBO8pY4+iJMPE1B9XlO2tXVYIcEA4SNGtvDELzTSCQO7RzH+j7S180BmhmJId78lqGU2z19vgVx2Sxs/PQ==" + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.5.7.tgz", + "integrity": "sha512-2q4bEI+coQM8f5ez7kt2xclg1XsecaV9ASJk/54vwlfRRNQfDqJz2pzQ8t0Ix/ToBpXlVjrRIx7pFC/o8itG2Q==" }, "node_modules/dotenv": { "version": "10.0.0", @@ -5908,16 +5908,16 @@ } }, "node_modules/engine.io": { - "version": "6.5.5", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.5.5.tgz", - "integrity": "sha512-C5Pn8Wk+1vKBoHghJODM63yk8MvrO9EWZUfkAt5HAqIgPE4/8FF0PEGHXtEd40l223+cE5ABWuPzm38PHFXfMA==", + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.2.tgz", + "integrity": "sha512-gmNvsYi9C8iErnZdVcJnvCpSKbWTt1E8+JZo8b+daLninywUWi5NQ5STSHZ9rFjFO7imNcvb8Pc5pe/wMR5xEw==", "dependencies": { "@types/cookie": "^0.4.1", "@types/cors": "^2.8.12", "@types/node": ">=10.0.0", "accepts": "~1.3.4", "base64id": "2.0.0", - "cookie": "~0.4.1", + "cookie": "~0.7.2", "cors": "~2.8.5", "debug": "~4.3.1", "engine.io-parser": "~5.2.1", @@ -6988,9 +6988,9 @@ "integrity": "sha512-J+ler7Ta54FwwNcx6wQRDhTIbNeyDcARMkOcguEqnEdtm0jKvN3Li3PDAb2Du3ubJYEWfYL83XMROXdsXAXycw==" }, "node_modules/form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.2.tgz", + "integrity": "sha512-sJe+TQb2vIaIyO783qN6BlMYWMw3WBOHA1Ay2qxsnjuafEOQFJ2JakedOQirT6D5XPRxDvS7AHYyem9fTpb4LQ==", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -9491,9 +9491,9 @@ } }, "node_modules/nwsapi": { - "version": "2.2.12", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.12.tgz", - "integrity": "sha512-qXDmcVlZV4XRtKFzddidpfVP4oMSGhga+xdMc25mv8kaLUHtgzCDhUxkrN8exkGdTlLNaXj7CV3GtON7zuGZ+w==" + "version": "2.2.13", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.13.tgz", + "integrity": "sha512-cTGB9ptp9dY9A5VbMSe7fQBcl/tt22Vcqdq8+eN93rblOuE0aCFu4aZ2vMwct/2t+lFnosm8RkQW1I0Omb1UtQ==" }, "node_modules/object-assign": { "version": "4.1.1", @@ -11794,15 +11794,15 @@ } }, "node_modules/socket.io": { - "version": "4.7.5", - "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.7.5.tgz", - "integrity": "sha512-DmeAkF6cwM9jSfmp6Dr/5/mfMwb5Z5qRrSXLpo3Fq5SqyU8CMF15jIN4ZhfSwu35ksM1qmHZDQ/DK5XTccSTvA==", + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.8.1.tgz", + "integrity": "sha512-oZ7iUCxph8WYRHHcjBEc9unw3adt5CmSNlppj/5Q4k2RIrhl8Z5yY2Xr4j9zj0+wzVZ0bxmYoGSzKJnRl6A4yg==", "dependencies": { "accepts": "~1.3.4", "base64id": "~2.0.0", "cors": "~2.8.5", "debug": "~4.3.2", - "engine.io": "~6.5.2", + "engine.io": "~6.6.0", "socket.io-adapter": "~2.5.2", "socket.io-parser": "~4.2.4" }, diff --git a/assets/create-glee-app/templates/default/package.json b/assets/create-glee-app/templates/default/package.json index e36ee27bd92..794018c1c17 100644 --- a/assets/create-glee-app/templates/default/package.json +++ b/assets/create-glee-app/templates/default/package.json @@ -24,7 +24,7 @@ }, "homepage": "https://github.com/asyncapi/glee-hello-world#readme", "dependencies": { - "@asyncapi/glee": "^0.37.8" + "@asyncapi/glee": "^0.37.9" }, "devDependencies": { "@types/node": "^20.5.9" diff --git a/assets/create-glee-app/templates/tutorial/package-lock.json b/assets/create-glee-app/templates/tutorial/package-lock.json index 4bf45a7827e..843c4583ae3 100644 --- a/assets/create-glee-app/templates/tutorial/package-lock.json +++ b/assets/create-glee-app/templates/tutorial/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.0", "license": "Apache-2.0", "dependencies": { - "@asyncapi/glee": "^0.37.8" + "@asyncapi/glee": "^0.37.9" }, "engines": { "node": ">=14.15.1" @@ -166,12 +166,12 @@ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" }, "node_modules/@asyncapi/glee": { - "version": "0.37.8", - "resolved": "https://registry.npmjs.org/@asyncapi/glee/-/glee-0.37.8.tgz", - "integrity": "sha512-1qa/OuOzA38AvuNu1w/wduXKnXjxtHMcCYggVoCQVIzJZ6lG9xaK73g3floUUDK5sMAqiytvisCyGVobXzv4Kw==", + "version": "0.37.9", + "resolved": "https://registry.npmjs.org/@asyncapi/glee/-/glee-0.37.9.tgz", + "integrity": "sha512-mruRd34RpE+0VoQ5jKA67a4d8qyJzTY42p6qGj0O7gpL2UB1tus8eP/cbapbyE0DB3LeMDhIu4m04yfYOlw6Gw==", "dependencies": { "@asyncapi/generator": "^1.17.25", - "@asyncapi/html-template": "^2.3.14", + "@asyncapi/html-template": "^3.0.0", "@asyncapi/markdown-template": "^1.6.6", "@asyncapi/parser": "^3.1.0", "@next/env": "^14.0.4", @@ -213,9 +213,9 @@ } }, "node_modules/@asyncapi/html-template": { - "version": "2.3.14", - "resolved": "https://registry.npmjs.org/@asyncapi/html-template/-/html-template-2.3.14.tgz", - "integrity": "sha512-e7jHGXNtovA2u9n0A9CtPy+xkXa76vpz+gdY/4q4TC4bm6EadEhcDiNQ0LtFnUjcHDuxXzYZs8/0BZr1vSBeQw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@asyncapi/html-template/-/html-template-3.0.0.tgz", + "integrity": "sha512-U5+fx9fdtQwi7C6PabODP01m1z596fhOjCcRdaOHI2/OBm2DFeQIDel2QZ1B1KmChouANaj0IC4lGfJgJcPw1g==", "dependencies": { "@asyncapi/generator-react-sdk": "^1.1.2", "@asyncapi/parser": "^3.1.0", @@ -5366,9 +5366,9 @@ "peer": true }, "node_modules/cookie": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", - "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", "engines": { "node": ">= 0.6" } @@ -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", @@ -5843,9 +5843,9 @@ } }, "node_modules/dompurify": { - "version": "2.5.6", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.5.6.tgz", - "integrity": "sha512-zUTaUBO8pY4+iJMPE1B9XlO2tXVYIcEA4SNGtvDELzTSCQO7RzH+j7S180BmhmJId78lqGU2z19vgVx2Sxs/PQ==" + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.5.7.tgz", + "integrity": "sha512-2q4bEI+coQM8f5ez7kt2xclg1XsecaV9ASJk/54vwlfRRNQfDqJz2pzQ8t0Ix/ToBpXlVjrRIx7pFC/o8itG2Q==" }, "node_modules/dotenv": { "version": "10.0.0", @@ -5905,16 +5905,16 @@ } }, "node_modules/engine.io": { - "version": "6.5.5", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.5.5.tgz", - "integrity": "sha512-C5Pn8Wk+1vKBoHghJODM63yk8MvrO9EWZUfkAt5HAqIgPE4/8FF0PEGHXtEd40l223+cE5ABWuPzm38PHFXfMA==", + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.2.tgz", + "integrity": "sha512-gmNvsYi9C8iErnZdVcJnvCpSKbWTt1E8+JZo8b+daLninywUWi5NQ5STSHZ9rFjFO7imNcvb8Pc5pe/wMR5xEw==", "dependencies": { "@types/cookie": "^0.4.1", "@types/cors": "^2.8.12", "@types/node": ">=10.0.0", "accepts": "~1.3.4", "base64id": "2.0.0", - "cookie": "~0.4.1", + "cookie": "~0.7.2", "cors": "~2.8.5", "debug": "~4.3.1", "engine.io-parser": "~5.2.1", @@ -6985,9 +6985,9 @@ "integrity": "sha512-J+ler7Ta54FwwNcx6wQRDhTIbNeyDcARMkOcguEqnEdtm0jKvN3Li3PDAb2Du3ubJYEWfYL83XMROXdsXAXycw==" }, "node_modules/form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.2.tgz", + "integrity": "sha512-sJe+TQb2vIaIyO783qN6BlMYWMw3WBOHA1Ay2qxsnjuafEOQFJ2JakedOQirT6D5XPRxDvS7AHYyem9fTpb4LQ==", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -9488,9 +9488,9 @@ } }, "node_modules/nwsapi": { - "version": "2.2.12", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.12.tgz", - "integrity": "sha512-qXDmcVlZV4XRtKFzddidpfVP4oMSGhga+xdMc25mv8kaLUHtgzCDhUxkrN8exkGdTlLNaXj7CV3GtON7zuGZ+w==" + "version": "2.2.13", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.13.tgz", + "integrity": "sha512-cTGB9ptp9dY9A5VbMSe7fQBcl/tt22Vcqdq8+eN93rblOuE0aCFu4aZ2vMwct/2t+lFnosm8RkQW1I0Omb1UtQ==" }, "node_modules/object-assign": { "version": "4.1.1", @@ -11791,15 +11791,15 @@ } }, "node_modules/socket.io": { - "version": "4.7.5", - "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.7.5.tgz", - "integrity": "sha512-DmeAkF6cwM9jSfmp6Dr/5/mfMwb5Z5qRrSXLpo3Fq5SqyU8CMF15jIN4ZhfSwu35ksM1qmHZDQ/DK5XTccSTvA==", + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.8.0.tgz", + "integrity": "sha512-8U6BEgGjQOfGz3HHTYaC/L1GaxDCJ/KM0XTkJly0EhZ5U/du9uNEZy4ZgYzEzIqlx2CMm25CrCqr1ck899eLNA==", "dependencies": { "accepts": "~1.3.4", "base64id": "~2.0.0", "cors": "~2.8.5", "debug": "~4.3.2", - "engine.io": "~6.5.2", + "engine.io": "~6.6.0", "socket.io-adapter": "~2.5.2", "socket.io-parser": "~4.2.4" }, diff --git a/assets/create-glee-app/templates/tutorial/package.json b/assets/create-glee-app/templates/tutorial/package.json index 1e67c9fa669..9b2b557fa98 100644 --- a/assets/create-glee-app/templates/tutorial/package.json +++ b/assets/create-glee-app/templates/tutorial/package.json @@ -16,6 +16,6 @@ "author": "Fran Mendez", "license": "Apache-2.0", "dependencies": { - "@asyncapi/glee": "^0.37.8" + "@asyncapi/glee": "^0.37.9" } } diff --git a/assets/create-template/templates/default/package-lock.json b/assets/create-template/templates/default/package-lock.json index 0231c20d08a..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": { @@ -3682,9 +3702,9 @@ } }, "node_modules/rollup": { - "version": "2.79.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz", - "integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==", + "version": "2.79.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.2.tgz", + "integrity": "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==", "bin": { "rollup": "dist/bin/rollup" }, diff --git a/docs/architecture.md b/docs/architecture.md new file mode 100644 index 00000000000..81216dac8ed --- /dev/null +++ b/docs/architecture.md @@ -0,0 +1,98 @@ +--- +title: 'CLI Architecture' +weight: 40 +--- + +The AsyncAPI CLI uses oclif (Open CLI Framework) as its core framework, which enables developers to build powerful and scalable command-line applications. + +**Structure of the AsyncAPI CLI**: The CLI is primarily divided into two components: commands and the core part. + +1. **Command Component**: The commands include all the necessary functionalities that help developers interact with features like creating new AsyncAPI projects, validating AsyncAPI files, formatting AsyncAPI files, and more. +2. **Core Component**: The core part of the CLI contains various utilities that facilitate the efficient creation of new commands. + +--- + +### **Detailed Explanation of Key Directories in the CLI** + +#### **`src/commands/`** +- **Purpose:** Implements the CLI commands available to the user. +- **Subdirectories:** + - `config/`: Stores configuration-related files for commands. + - `generate/`: Generates typed models or other artifacts like clients, applications, or documentation using AsyncAPI Generator templates. + - **Files:** + - `fromTemplate.ts`: Contains logic for generating files using templates. + - `models.ts`: Defines the models used during generation. + - `new/`: Creates a new AsyncAPI file. + - **Files:** + - `file.ts`: Handles file creation logic. + - `glee.ts`: Related to Glee, a tool for event-driven microservices. + - `template.ts`: Manages templates for new projects. + - `start/`: Implements starting functionalities like launching a local server or studio. + - **Files:** + - `studio.ts`: Integrates with the AsyncAPI Studio. + +- **Standalone Files:** + - `bundle.ts`: Bundles one or multiple AsyncAPI documents and their references together. + - `convert.ts`: Converts AsyncAPI documents from older to newer versions or transforms OpenAPI/Postman-collection documents into AsyncAPI. + - `diff.ts`: Compares two AsyncAPI documents. + - `format.ts`: Converts AsyncAPI documents from any format to YAML, YML, or JSON. + - `optimize.ts`: Optimizes AsyncAPI documents for performance. + - `pretty.ts`: Beautifies the AsyncAPI spec file (indentation, styling) in place or outputs the formatted spec to a new file. + - `validate.ts`: Validates AsyncAPI documents for correctness. + +--- + +#### **`src/core/`** +- **Purpose:** Provides foundational components and utilities for the CLI. +- **Subdirectories:** + - `errors/`: Centralized error definitions. + - `flags/`: Defines CLI flags and their behavior. + - `hooks/`: Event hooks used for customization. + - `models/`: Core data models used across the application. + - `utils/`: Utility functions for common operations. + +- **Standalone Files:** + - `base.ts`: Base class or logic for CLI commands. + - `global.d.ts`: Global TypeScript definitions. + - `globals.ts`: Stores global variables and configurations. + - `parser.ts`: Parses AsyncAPI documents. + +--- + +#### **`test/`** +- **Purpose:** Implements the test suite for the CLI. +- **Subdirectories:** + - `fixtures/`: Contains mock data or files for testing. + - `hooks/`: Tests related to hooks. + - `integration/`: Integration tests to verify end-to-end functionality. + - `system/`: System-level tests. + - `unit/`: Unit tests for individual modules or functions. + +--- + +### **Use Cases** + +1. **Generate AsyncAPI Artifacts:** + - Use the `generate` command to create client/server code, documentation, or other artifacts based on AsyncAPI templates. + +2. **Create New Projects:** + - The `new` command helps users scaffold new AsyncAPI projects with predefined templates. + +3. **Validate AsyncAPI Documents:** + - The `validate` command ensures AsyncAPI documents conform to the specification. + +4. **Optimize and Format Documents:** + - The `optimize` and `pretty` commands provide tools for improving document readability and performance. + +5. **Compare Documents:** + - The `diff` command enables comparison between two AsyncAPI documents to track changes. + +6. **Integration with AsyncAPI Studio:** + - The `start` command integrates with the AsyncAPI Studio for editing and visualizing documents. + +7. **Convert Between Formats:** + - The `convert` command supports converting AsyncAPI documents between formats like YAML and JSON. + +--- + +This structure ensures the CLI is modular, scalable, and easy to maintain. Let me know if you need further clarification or additional details! \ No newline at end of file diff --git a/docs/context.md b/docs/context.md index 30803782e55..2a64fab21ef 100644 --- a/docs/context.md +++ b/docs/context.md @@ -1,6 +1,6 @@ --- title: 'Context concept' -weight: 50 +weight: 60 --- ## Overview diff --git a/docs/metrics_collection.md b/docs/metrics_collection.md index cd9a4c6f777..4df0dec069e 100644 --- a/docs/metrics_collection.md +++ b/docs/metrics_collection.md @@ -1,6 +1,6 @@ --- title: 'Metrics Collection' -weight: 60 +weight: 70 --- # Metrics collection guideline diff --git a/docs/usage.md b/docs/usage.md index 3a1ddf96022..c6540674051 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.4.1 linux-x64 node-v18.20.4 +@asyncapi/cli/2.14.1 linux-x64 node-v18.20.5 $ asyncapi --help [COMMAND] USAGE $ asyncapi COMMAND @@ -50,8 +50,9 @@ USAGE * [`asyncapi config context remove CONTEXT-NAME`](#asyncapi-config-context-remove-context-name) * [`asyncapi config context use CONTEXT-NAME`](#asyncapi-config-context-use-context-name) * [`asyncapi config versions`](#asyncapi-config-versions) -* [`asyncapi convert [SPEC-FILE]`](#asyncapi-convert-spec-file) +* [`asyncapi convert [SPEC-FILE] [PROXYHOST] [PROXYPORT]`](#asyncapi-convert-spec-file-proxyhost-proxyport) * [`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) @@ -59,10 +60,11 @@ USAGE * [`asyncapi new file`](#asyncapi-new-file) * [`asyncapi new glee`](#asyncapi-new-glee) * [`asyncapi new template`](#asyncapi-new-template) -* [`asyncapi optimize [SPEC-FILE]`](#asyncapi-optimize-spec-file) +* [`asyncapi optimize [SPEC-FILE] [PROXYHOST] [PROXYPORT]`](#asyncapi-optimize-spec-file-proxyhost-proxyport) +* [`asyncapi pretty SPEC-FILE`](#asyncapi-pretty-spec-file) * [`asyncapi start`](#asyncapi-start) * [`asyncapi start studio`](#asyncapi-start-studio) -* [`asyncapi validate [SPEC-FILE]`](#asyncapi-validate-spec-file) +* [`asyncapi validate [SPEC-FILE] [PROXYHOST] [PROXYPORT]`](#asyncapi-validate-spec-file-proxyhost-proxyport) ## `asyncapi bundle` @@ -99,7 +101,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.4.1/src/commands/bundle.ts)_ +_See code: [src/commands/bundle.ts](https://github.com/asyncapi/cli/blob/v2.14.1/src/commands/bundle.ts)_ ## `asyncapi config` @@ -113,7 +115,7 @@ DESCRIPTION CLI config settings ``` -_See code: [src/commands/config/index.ts](https://github.com/asyncapi/cli/blob/v2.4.1/src/commands/config/index.ts)_ +_See code: [src/commands/config/index.ts](https://github.com/asyncapi/cli/blob/v2.14.1/src/commands/config/index.ts)_ ## `asyncapi config analytics` @@ -133,7 +135,7 @@ DESCRIPTION Enable or disable analytics for metrics collection ``` -_See code: [src/commands/config/analytics.ts](https://github.com/asyncapi/cli/blob/v2.4.1/src/commands/config/analytics.ts)_ +_See code: [src/commands/config/analytics.ts](https://github.com/asyncapi/cli/blob/v2.14.1/src/commands/config/analytics.ts)_ ## `asyncapi config context` @@ -147,7 +149,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.4.1/src/commands/config/context/index.ts)_ +_See code: [src/commands/config/context/index.ts](https://github.com/asyncapi/cli/blob/v2.14.1/src/commands/config/context/index.ts)_ ## `asyncapi config context add CONTEXT-NAME SPEC-FILE-PATH` @@ -169,7 +171,7 @@ DESCRIPTION Add a context to the store ``` -_See code: [src/commands/config/context/add.ts](https://github.com/asyncapi/cli/blob/v2.4.1/src/commands/config/context/add.ts)_ +_See code: [src/commands/config/context/add.ts](https://github.com/asyncapi/cli/blob/v2.14.1/src/commands/config/context/add.ts)_ ## `asyncapi config context current` @@ -186,7 +188,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.4.1/src/commands/config/context/current.ts)_ +_See code: [src/commands/config/context/current.ts](https://github.com/asyncapi/cli/blob/v2.14.1/src/commands/config/context/current.ts)_ ## `asyncapi config context edit CONTEXT-NAME NEW-SPEC-FILE-PATH` @@ -207,7 +209,7 @@ DESCRIPTION Edit a context in the store ``` -_See code: [src/commands/config/context/edit.ts](https://github.com/asyncapi/cli/blob/v2.4.1/src/commands/config/context/edit.ts)_ +_See code: [src/commands/config/context/edit.ts](https://github.com/asyncapi/cli/blob/v2.14.1/src/commands/config/context/edit.ts)_ ## `asyncapi config context init [CONTEXT-FILE-PATH]` @@ -230,7 +232,7 @@ DESCRIPTION Initialize context ``` -_See code: [src/commands/config/context/init.ts](https://github.com/asyncapi/cli/blob/v2.4.1/src/commands/config/context/init.ts)_ +_See code: [src/commands/config/context/init.ts](https://github.com/asyncapi/cli/blob/v2.14.1/src/commands/config/context/init.ts)_ ## `asyncapi config context list` @@ -247,7 +249,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.4.1/src/commands/config/context/list.ts)_ +_See code: [src/commands/config/context/list.ts](https://github.com/asyncapi/cli/blob/v2.14.1/src/commands/config/context/list.ts)_ ## `asyncapi config context remove CONTEXT-NAME` @@ -267,7 +269,7 @@ DESCRIPTION Delete a context from the store ``` -_See code: [src/commands/config/context/remove.ts](https://github.com/asyncapi/cli/blob/v2.4.1/src/commands/config/context/remove.ts)_ +_See code: [src/commands/config/context/remove.ts](https://github.com/asyncapi/cli/blob/v2.14.1/src/commands/config/context/remove.ts)_ ## `asyncapi config context use CONTEXT-NAME` @@ -287,7 +289,7 @@ DESCRIPTION Set a context as current ``` -_See code: [src/commands/config/context/use.ts](https://github.com/asyncapi/cli/blob/v2.4.1/src/commands/config/context/use.ts)_ +_See code: [src/commands/config/context/use.ts](https://github.com/asyncapi/cli/blob/v2.14.1/src/commands/config/context/use.ts)_ ## `asyncapi config versions` @@ -304,34 +306,39 @@ DESCRIPTION Show versions of AsyncAPI tools used ``` -_See code: [src/commands/config/versions.ts](https://github.com/asyncapi/cli/blob/v2.4.1/src/commands/config/versions.ts)_ +_See code: [src/commands/config/versions.ts](https://github.com/asyncapi/cli/blob/v2.14.1/src/commands/config/versions.ts)_ -## `asyncapi convert [SPEC-FILE]` +## `asyncapi convert [SPEC-FILE] [PROXYHOST] [PROXYPORT]` -Convert asyncapi documents older to newer versions or OpenAPI documents to AsyncAPI +Convert asyncapi documents older to newer versions or OpenAPI/postman-collection documents to AsyncAPI ``` USAGE - $ asyncapi convert [SPEC-FILE] -f openapi|asyncapi [-h] [-o ] [-t ] [-p client|server] + $ asyncapi convert [SPEC-FILE] [PROXYHOST] [PROXYPORT] -f openapi|asyncapi|postman-collection [-h] [-o + ] [-t ] [-p client|server] [--proxyHost ] [--proxyPort ] ARGUMENTS SPEC-FILE spec path, url, or context-name + PROXYHOST Name of the Proxy Host + PROXYPORT Name of the Port of the ProxyHost FLAGS -f, --format=