From ef5e32e1c7408c3297534fe83a40e8db392d12a5 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Sat, 21 Sep 2024 15:35:09 +0530 Subject: [PATCH 01/20] setup --- scripts/build-tools.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/build-tools.js b/scripts/build-tools.js index 363e3418816..1993432273b 100644 --- a/scripts/build-tools.js +++ b/scripts/build-tools.js @@ -6,18 +6,21 @@ const manualTools = require('../config/tools-manual.json') const fs = require('fs'); const { resolve } = require('path'); +const toolsPath = resolve(__dirname, '../../config', 'tools.json') +const tagsPath = resolve(__dirname, '../../config', 'all-tags.json') +const automatedToolsPath = resolve(__dirname, '../config', 'tools-automated.json') + const buildTools = async () => { try { let githubExtractData = await getData(); let automatedTools = await convertTools(githubExtractData); fs.writeFileSync( - resolve(__dirname, '../config', 'tools-automated.json'), + automatedToolsPath, JSON.stringify(automatedTools, null, ' ') ); - await combineTools(automatedTools, manualTools); + await combineTools(automatedTools, manualTools, toolsPath, tagsPath); } catch (err) { - console.log(err); - throw err + throw new Error("An error occurred while building tools:", err.message); } }; From fdddfe12d06ea391d9a3b941a0f613d0aee401f6 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Sat, 21 Sep 2024 16:05:17 +0530 Subject: [PATCH 02/20] added tests for errors --- config/tools-automated.json | 874 +----------------------------------- scripts/build-tools.js | 8 +- tests/build-tools.test.js | 116 +++++ 3 files changed, 131 insertions(+), 867 deletions(-) create mode 100644 tests/build-tools.test.js diff --git a/config/tools-automated.json b/config/tools-automated.json index 504b55f18f8..f312c1cf140 100644 --- a/config/tools-automated.json +++ b/config/tools-automated.json @@ -1,866 +1,10 @@ -{ - "APIs": { - "description": "The following is a list of APIs that expose functionality related to AsyncAPI.", - "toolsList": [ - { - "title": "AsyncAPI Server API", - "description": "Server API providing official AsyncAPI tools", - "links": { - "websiteUrl": "https://api.asyncapi.com/v1", - "docsUrl": "https://api.asyncapi.com/v1/docs", - "repoUrl": "https://github.com/asyncapi/server-api" - }, - "filters": { - "technology": [ - "Node.js", - "TypeScript" - ], - "categories": [ - "api" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - }, - { - "title": "SIO-AsyncAPI", - "description": "This is code-first approach to generate AsyncAPI specification from Socket.IO server.", - "links": { - "websiteUrl": "https://github.com/daler-rahimov/sio-asyncapi", - "docsUrl": "https://github.com/daler-rahimov/sio-asyncapi", - "repoUrl": "https://github.com/daler-rahimov/sio-asyncapi" - }, - "filters": { - "language": "Python", - "technology": [ - "Socket.IO", - "Flask" - ], - "categories": [ - "code-first", - "api" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - } - ] - }, - "Code-first tools": { - "description": "The following is a list of tools that generate AsyncAPI documents from your code.", - "toolsList": [ - { - "title": "AsyncAPI.Net", - "description": "The AsyncAPI.NET SDK contains a useful object model for AsyncAPI documents in .NET along with common serializers to extract raw OpenAPI JSON and YAML documents from the model.", - "links": { - "websiteUrl": "https://github.com/LEGO/AsyncAPI.NET/", - "repoUrl": "https://github.com/LEGO/AsyncAPI.NET" - }, - "filters": { - "language": "C#", - "technology": [ - ".NET", - "ASP.NET" - ], - "categories": [ - "converters", - "code-first", - "validator" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - }, - { - "title": "nestjs-asyncapi", - "description": "Utilize decorators to generate AsyncAPI document utilizing DTOs (similar to @nestjs/swagger) and a web UI.", - "links": { - "repoUrl": "https://github.com/flamewow/nestjs-asyncapi" - }, - "filters": { - "language": "Typescript", - "technology": [ - "Node.js", - "NestJS" - ], - "categories": [ - "code-first" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - }, - { - "title": "SIO-AsyncAPI", - "description": "This is code-first approach to generate AsyncAPI specification from Socket.IO server.", - "links": { - "websiteUrl": "https://github.com/daler-rahimov/sio-asyncapi", - "docsUrl": "https://github.com/daler-rahimov/sio-asyncapi", - "repoUrl": "https://github.com/daler-rahimov/sio-asyncapi" - }, - "filters": { - "language": "Python", - "technology": [ - "Socket.IO", - "Flask" - ], - "categories": [ - "code-first", - "api" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - }, - { - "title": "Zod Sockets", - "description": "Socket.IO solution with I/O validation and the ability to generate AsyncAPI specification and a contract for consumers.", - "links": { - "websiteUrl": "https://www.npmjs.com/package/zod-sockets", - "repoUrl": "https://github.com/RobinTail/zod-sockets" - }, - "filters": { - "language": "TypeScript", - "technology": [ - "Node.js", - "TypeScript" - ], - "categories": [ - "code-first", - "dsl", - "framework" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - } - ] - }, - "Code Generators": { - "description": "The following is a list of tools that generate code from an AsyncAPI document; not the other way around.", - "toolsList": [ - { - "title": "Golang AsyncAPI Code Generator", - "description": "Generate Go user and application boilerplate from AsyncAPI specifications. Can be called from `go generate` without requirements.\n", - "links": { - "repoUrl": "https://github.com/lerenn/asyncapi-codegen" - }, - "filters": { - "language": "golang", - "categories": [ - "code-generator" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - }, - { - "title": "ZenWave SDK", - "description": "DDD and API-First for Event-Driven Microservices", - "links": { - "websiteUrl": "https://zenwave360.github.io/", - "docsUrl": "https://zenwave360.github.io/zenwave-sdk/plugins/asyncapi-spring-cloud-streams3/", - "repoUrl": "https://github.com/zenwave360/zenwave-sdk" - }, - "filters": { - "language": "Java", - "technology": [ - "Maven", - "CLI", - "Spring Cloud Streams", - "JHipster JDL" - ], - "categories": [ - "code-generator", - "dsl", - "mocking-and-testing", - "cli" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - }, - { - "title": "AsyncAPI Modelina", - "description": "Generate payload models into Java, TypeScript, Go, etc, you name it, from AsyncAPI documents. This tool gives you full control over the models through high customization", - "links": { - "websiteUrl": "https://modelina.org", - "docsUrl": "https://github.com/asyncapi/modelina/tree/master/docs", - "repoUrl": "https://github.com/asyncapi/modelina" - }, - "filters": { - "language": "TypeScript", - "technology": [ - "React JS", - "Docker" - ], - "categories": [ - "code-generator" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - } - ] - }, - "Converters": { - "description": "The following is a list of tools that do not yet belong to any specific category but are also useful for the community.", - "toolsList": [ - { - "title": "AsyncAPI.Net", - "description": "The AsyncAPI.NET SDK contains a useful object model for AsyncAPI documents in .NET along with common serializers to extract raw OpenAPI JSON and YAML documents from the model.", - "links": { - "websiteUrl": "https://github.com/LEGO/AsyncAPI.NET/", - "repoUrl": "https://github.com/LEGO/AsyncAPI.NET" - }, - "filters": { - "language": "C#", - "technology": [ - ".NET", - "ASP.NET" - ], - "categories": [ - "converters", - "code-first", - "validator" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - } - ] - }, - "Directories": { - "description": "The following is a list of directories that index public AsyncAPI documents.", - "toolsList": [] - }, - "Documentation Generators": { - "description": "The following is a list of tools that generate human-readable documentation from an AsyncAPI document.", - "toolsList": [] - }, - "Editors": { - "description": "The following is a list of editors or related tools that allow editing of AsyncAPI document.", - "toolsList": [ - { - "title": "AsyncAPI Studio", - "description": "Visually design your AsyncAPI files and event-driven architecture.", - "links": { - "websiteUrl": "https://studio.asyncapi.com", - "repoUrl": "https://github.com/asyncapi/studio" - }, - "filters": { - "technology": [ - "React JS", - "TypeScript" - ], - "categories": [ - "editor" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - } - ] - }, - "UI components": { - "description": "The following is a list of UI components to view AsyncAPI documents.", - "toolsList": [ - { - "title": "AsyncAPI React component", - "description": "React component for rendering documentation from your specification in real-time in the browser. It also provides a WebComponent and bundle for Angular and Vue", - "links": { - "repoUrl": "https://github.com/asyncapi/asyncapi-react" - }, - "filters": { - "language": "TypeScript", - "technology": [ - "React js", - "WebComponents" - ], - "categories": [ - "ui-component" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - } - ] - }, - "DSL": { - "description": "Writing YAML by hand is no fun, and maybe you don't want a GUI, so use a Domain Specific Language to write AsyncAPI in your language of choice.", - "toolsList": [ - { - "title": "ZenWave SDK", - "description": "DDD and API-First for Event-Driven Microservices", - "links": { - "websiteUrl": "https://zenwave360.github.io/", - "docsUrl": "https://zenwave360.github.io/zenwave-sdk/plugins/asyncapi-spring-cloud-streams3/", - "repoUrl": "https://github.com/zenwave360/zenwave-sdk" - }, - "filters": { - "language": "Java", - "technology": [ - "Maven", - "CLI", - "Spring Cloud Streams", - "JHipster JDL" - ], - "categories": [ - "code-generator", - "dsl", - "mocking-and-testing", - "cli" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - }, - { - "title": "Zod Sockets", - "description": "Socket.IO solution with I/O validation and the ability to generate AsyncAPI specification and a contract for consumers.", - "links": { - "websiteUrl": "https://www.npmjs.com/package/zod-sockets", - "repoUrl": "https://github.com/RobinTail/zod-sockets" - }, - "filters": { - "language": "TypeScript", - "technology": [ - "Node.js", - "TypeScript" - ], - "categories": [ - "code-first", - "dsl", - "framework" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - } - ] - }, - "Frameworks": { - "description": "The following is a list of API/application frameworks that make use of AsyncAPI.", - "toolsList": [ - { - "title": "Zod Sockets", - "description": "Socket.IO solution with I/O validation and the ability to generate AsyncAPI specification and a contract for consumers.", - "links": { - "websiteUrl": "https://www.npmjs.com/package/zod-sockets", - "repoUrl": "https://github.com/RobinTail/zod-sockets" - }, - "filters": { - "language": "TypeScript", - "technology": [ - "Node.js", - "TypeScript" - ], - "categories": [ - "code-first", - "dsl", - "framework" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - } - ] - }, - "GitHub Actions": { - "description": "The following is a list of GitHub Actions that you can use in your workflows", - "toolsList": [ - { - "title": "GitHub Action for Generator", - "description": null, - "links": { - "repoUrl": "https://github.com/actions-marketplace-validations/asyncapi_github-action-for-generator" - }, - "filters": { - "technology": [ - "AsyncAPI Generator" - ], - "categories": [ - "github-action" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - }, - { - "title": "GitHub Action for CLI", - "description": "GitHub Action with generator, validator, converter and others - all in one for your AsyncAPI documents with AsyncAPI CLI as backbone", - "links": { - "repoUrl": "https://github.com/asyncapi/github-action-for-cli" - }, - "filters": { - "technology": [ - "AsyncAPI CLI" - ], - "categories": [ - "github-action" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - } - ] - }, - "Mocking and Testing": { - "description": "The tools below take specification documents as input, then publish fake messages to broker destinations for simulation purposes. They may also check that publisher messages are compliant with schemas.", - "toolsList": [ - { - "title": "Specmatic", - "description": "An API contract testing tool that helps ensure the correctness APIs by automatically generating test cases and verifying them against the API spec. It simplifies the process of testing APIs and reduces the likelihood of bugs and compatibility issues.", - "links": { - "websiteUrl": "https://specmatic.io", - "docsUrl": "https://specmatic.io/documentation/", - "repoUrl": "https://github.com/znsio/specmatic" - }, - "filters": { - "language": "kotlin", - "technology": [ - "maven" - ], - "categories": [ - "mocking-and-testing" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - }, - { - "title": "ZenWave SDK", - "description": "DDD and API-First for Event-Driven Microservices", - "links": { - "websiteUrl": "https://zenwave360.github.io/", - "docsUrl": "https://zenwave360.github.io/zenwave-sdk/plugins/asyncapi-spring-cloud-streams3/", - "repoUrl": "https://github.com/zenwave360/zenwave-sdk" - }, - "filters": { - "language": "Java", - "technology": [ - "Maven", - "CLI", - "Spring Cloud Streams", - "JHipster JDL" - ], - "categories": [ - "code-generator", - "dsl", - "mocking-and-testing", - "cli" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - } - ] - }, - "Validators": { - "description": "The following is a list of tools that validate AsyncAPI documents.", - "toolsList": [ - { - "title": "AsyncAPI.Net", - "description": "The AsyncAPI.NET SDK contains a useful object model for AsyncAPI documents in .NET along with common serializers to extract raw OpenAPI JSON and YAML documents from the model.", - "links": { - "websiteUrl": "https://github.com/LEGO/AsyncAPI.NET/", - "repoUrl": "https://github.com/LEGO/AsyncAPI.NET" - }, - "filters": { - "language": "C#", - "technology": [ - ".NET", - "ASP.NET" - ], - "categories": [ - "converters", - "code-first", - "validator" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - }, - { - "title": "AsyncAPI Validation", - "description": "Message validation package for YAML and JSON AsyncAPI documents.", - "links": { - "repoUrl": "https://github.com/Elhebert/asyncapi-validation" - }, - "filters": { - "language": "TypeScript", - "technology": [ - "Node.js" - ], - "categories": [ - "validator" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - } - ] - }, - "Compare tools": { - "description": "The following is a list of tools that compare AsyncAPI documents.", - "toolsList": [ - { - "title": "jasyncapicmp", - "description": "Tool for comparing two AsyncAPI versions and evaluating compatibility.", - "links": { - "websiteUrl": "https://siom79.github.io/jasyncapicmp/", - "docsUrl": "https://github.com/siom79/jasyncapicmp", - "repoUrl": "https://github.com/siom79/jasyncapicmp" - }, - "filters": { - "language": "Java", - "technology": [ - "Maven" - ], - "categories": [ - "compare-tool" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - }, - { - "title": "AsyncAPI Diff", - "description": "Diff is a library that compares two AsyncAPI Documents and provides information about the differences by pointing out explicitly information like breaking changes.", - "links": { - "repoUrl": "https://github.com/asyncapi/diff" - }, - "filters": { - "language": "TypeScript", - "technology": [ - "TypeScript" - ], - "categories": [ - "compare-tool" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - } - ] - }, - "CLIs": { - "description": "The following is a list of tools that you can work with in terminal or do some CI/CD automation.", - "toolsList": [ - { - "title": "AsyncAPI CLI", - "description": "One CLI to rule them all. \nThis is a CLI that aims to integrate all AsyncAPI tools that you need while AsyncAPI document development and maintainance. \nYou can use it to generate docs or code, validate AsyncAPI document and event create new documents.\n", - "links": { - "websiteUrl": "https://www.asyncapi.com/tools/cli", - "repoUrl": "https://github.com/asyncapi/cli" - }, - "filters": { - "technology": [ - "TypeScript" - ], - "categories": [ - "others", - "cli" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - }, - { - "title": "ZenWave SDK", - "description": "DDD and API-First for Event-Driven Microservices", - "links": { - "websiteUrl": "https://zenwave360.github.io/", - "docsUrl": "https://zenwave360.github.io/zenwave-sdk/plugins/asyncapi-spring-cloud-streams3/", - "repoUrl": "https://github.com/zenwave360/zenwave-sdk" - }, - "filters": { - "language": "Java", - "technology": [ - "Maven", - "CLI", - "Spring Cloud Streams", - "JHipster JDL" - ], - "categories": [ - "code-generator", - "dsl", - "mocking-and-testing", - "cli" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - }, - { - "title": "AsyncAPI CLI", - "description": "One CLI to rule them all. \nThis is a CLI that aims to integrate all AsyncAPI tools that you need while AsyncAPI document development and maintainance. \nYou can use it to generate docs or code, validate AsyncAPI document and event create new documents.\n", - "links": { - "websiteUrl": "https://www.asyncapi.com/tools/cli", - "repoUrl": "https://github.com/hkirat/asyncapi-fork" - }, - "filters": { - "technology": [ - "TypeScript" - ], - "categories": [ - "others", - "cli" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - } - ] - }, - "Bundlers": { - "description": "The following is a list of tools that you can work with to bundle AsyncAPI documents.", - "toolsList": [ - { - "title": "AsyncAPI Bundler", - "description": "Combine multiple AsyncAPI specification files into one.", - "links": { - "repoUrl": "https://github.com/asyncapi/bundler" - }, - "filters": { - "language": "TypeScript", - "technology": [ - "TypeScript" - ], - "categories": [ - "bundler" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - } - ] - }, - "IDE Extensions": { - "description": "The following is a list of extensions for different IDEs like VSCode, IntelliJ IDEA and others", - "toolsList": [ - { - "title": "jAsyncAPI - IDEA plugin", - "description": "Idea plugin for the java-asyncapi - Helps to edit and validate AsyncAPI schemas.", - "links": { - "websiteUrl": "https://plugins.jetbrains.com/plugin/15673-asyncapi", - "docsUrl": "https://github.com/asyncapi/jasyncapi-idea-plugin#usage", - "repoUrl": "https://github.com/asyncapi/jasyncapi-idea-plugin" - }, - "filters": { - "language": "Kotlin", - "technology": [ - "JetBrains", - "IntelliJ IDEA" - ], - "categories": [ - "ide-extension" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - }, - { - "title": "asyncapi-preview", - "description": "VSCode extension that enables you to:\n - Preview documentation generated using you AsyncAPI document. It uses AsyncAPI React component under the hood,\n - Create AsyncAPI documents faster using SmartPaste functionality\n", - "links": { - "repoUrl": "https://github.com/asyncapi/vs-asyncapi-preview" - }, - "filters": { - "technology": [ - "VSCode", - "SmartPaste" - ], - "categories": [ - "ide-extension" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - }, - { - "title": "asyncapi-preview", - "description": "VSCode extension that enables you to:\n - Preview documentation generated using you AsyncAPI document. It uses AsyncAPI React component under the hood,\n - Create AsyncAPI documents faster using SmartPaste functionality\n", - "links": { - "repoUrl": "https://github.com/Savio629/testing2" - }, - "filters": { - "technology": [ - "VSCode", - "SmartPaste" - ], - "categories": [ - "ide-extension" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - } - ] - }, - "AsyncAPI Generator Templates": { - "description": "The following is a list of templates compatible with AsyncAPI Generator. You can use them to generate apps, clients or documentation from your AsyncAPI documents.", - "toolsList": [ - { - "title": "Node.js Websockets Template", - "description": "Node.js WebSockets template for the AsyncAPI Generator. It showcases how from a single AsyncAPI document you can generate a server and a client at the same time.", - "links": { - "repoUrl": "https://github.com/asyncapi/nodejs-ws-template" - }, - "filters": { - "language": "javascript", - "technology": [ - "Node.js" - ], - "categories": [ - "generator-template" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - }, - { - "title": "Java Template", - "description": "Java template for the AsyncAPI Generator", - "links": { - "repoUrl": "https://github.com/asyncapi/java-template" - }, - "filters": { - "language": [ - "javascript" - ], - "technology": [ - "Java" - ], - "categories": [ - "generator-template" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - }, - { - "title": "Java Spring Cloud Stream Template", - "description": "Java Spring Cloud Stream template for the AsyncAPI Generator", - "links": { - "repoUrl": "https://github.com/asyncapi/java-spring-cloud-stream-template" - }, - "filters": { - "language": [ - "javascript" - ], - "technology": [ - "Spring Cloud Streams", - "Maven" - ], - "categories": [ - "generator-template" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - }, - { - "title": "Node.js Multiprotocol Template", - "description": "This template generates a server using your AsyncAPI document. It supports multiple different protocols, like Kafka or MQTT. It is designed in the way that generated code is a library and with it's API you can start the server, send messages or register a middleware for listening incoming messages. Runtime message validation included.", - "links": { - "repoUrl": "https://github.com/asyncapi/nodejs-template" - }, - "filters": { - "language": "javascript", - "technology": [ - "Node.js" - ], - "categories": [ - "generator-template" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - }, - { - "title": "HTML Template", - "description": "HTML template for AsyncAPI Generator. Use it to generate a static docs. It is using AsyncAPI React component under the hood.", - "links": { - "repoUrl": "https://github.com/asyncapi/html-template" - }, - "filters": { - "language": "javascript", - "technology": [ - "HTML" - ], - "categories": [ - "generator-template" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - }, - { - "title": "Java Spring Template", - "description": "Java Spring template for the AsyncAPI Generator", - "links": { - "repoUrl": "https://github.com/asyncapi/java-spring-template" - }, - "filters": { - "language": [ - "javascript" - ], - "technology": [ - "Springboot", - "Maven", - "Gradle" - ], - "categories": [ - "generator-template" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - } - ] - }, - "Others": { - "description": "The following is a list of tools that comes under Other category.", - "toolsList": [ - { - "title": "AsyncAPI CLI", - "description": "One CLI to rule them all. \nThis is a CLI that aims to integrate all AsyncAPI tools that you need while AsyncAPI document development and maintainance. \nYou can use it to generate docs or code, validate AsyncAPI document and event create new documents.\n", - "links": { - "websiteUrl": "https://www.asyncapi.com/tools/cli", - "repoUrl": "https://github.com/asyncapi/cli" - }, - "filters": { - "technology": [ - "TypeScript" - ], - "categories": [ - "others", - "cli" - ], - "hasCommercial": false, - "isAsyncAPIOwner": true - } - }, - { - "title": "AsyncAPI CLI", - "description": "One CLI to rule them all. \nThis is a CLI that aims to integrate all AsyncAPI tools that you need while AsyncAPI document development and maintainance. \nYou can use it to generate docs or code, validate AsyncAPI document and event create new documents.\n", - "links": { - "websiteUrl": "https://www.asyncapi.com/tools/cli", - "repoUrl": "https://github.com/hkirat/asyncapi-fork" - }, - "filters": { - "technology": [ - "TypeScript" - ], - "categories": [ - "others", - "cli" - ], - "hasCommercial": false, - "isAsyncAPIOwner": false - } - } - ] +[ + { + "id": 1, + "tool": "tool1" + }, + { + "id": 2, + "tool": "tool2" } -} \ No newline at end of file +] \ No newline at end of file diff --git a/scripts/build-tools.js b/scripts/build-tools.js index 1993432273b..1809e6a8d8b 100644 --- a/scripts/build-tools.js +++ b/scripts/build-tools.js @@ -20,8 +20,12 @@ const buildTools = async () => { ); await combineTools(automatedTools, manualTools, toolsPath, tagsPath); } catch (err) { - throw new Error("An error occurred while building tools:", err.message); + throw new Error(`An error occurred while building tools: ${err.message}`); } }; -buildTools(); \ No newline at end of file +if (require.main === module) { + buildTools(); +} + +module.exports = {buildTools} \ No newline at end of file diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js new file mode 100644 index 00000000000..123671cc261 --- /dev/null +++ b/tests/build-tools.test.js @@ -0,0 +1,116 @@ +const { readFileSync, rmSync, mkdirSync, writeFileSync } = require('fs'); +const { resolve } = require('path'); +const { getData } = require('../scripts/tools/extract-tools-github'); +const { convertTools } = require('../scripts/tools/tools-object'); +const { combineTools } = require('../scripts/tools/combine-tools'); +const { buildTools } = require('../scripts/build-tools'); + +jest.mock('../scripts/tools/extract-tools-github'); +jest.mock('../scripts/tools/tools-object'); +jest.mock('../scripts/tools/combine-tools'); + +describe('buildTools', () => { + const testDir = resolve(__dirname, 'test_config'); + const toolsPath = resolve(testDir, 'tools.json'); + const tagsPath = resolve(testDir, 'all-tags.json'); + const automatedToolsPath = resolve(testDir, 'tools-automated.json'); + const manualToolsPath = resolve(testDir, 'tools-manual.json'); + + beforeAll(() => { + mkdirSync(testDir, { recursive: true }); + // Create a temporary tools-manual.json + const manualTools = [ + { id: 1, tool: 'manualTool1' }, + { id: 2, tool: 'manualTool2' } + ]; + writeFileSync(manualToolsPath, JSON.stringify(manualTools)); + }); + + afterAll(() => { + rmSync(testDir, { recursive: true, force: true }); + }); + + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('should extract, convert, combine tools, and write to file', async () => { + const mockExtractData = [{ name: 'tool1' }, { name: 'tool2' }]; + const mockConvertedData = [{ id: 1, tool: 'tool1' }, { id: 2, tool: 'tool2' }]; + + getData.mockResolvedValue(mockExtractData); + convertTools.mockResolvedValue(mockConvertedData); + combineTools.mockResolvedValue(true); + + await buildTools(); + + // Check if the automated tools file is written + const automatedToolsContent = readFileSync(automatedToolsPath, 'utf8'); + expect(JSON.parse(automatedToolsContent)).toEqual(mockConvertedData); + + // Check if combineTools is called with correct arguments + expect(combineTools).toHaveBeenCalledWith(mockConvertedData, JSON.parse(readFileSync(manualToolsPath, 'utf8')), toolsPath, tagsPath); + + // Check if tools and tags files are written + const toolsContent = readFileSync(toolsPath, 'utf8'); + const tagsContent = readFileSync(tagsPath, 'utf8'); + + expect(toolsContent).toBeDefined(); + expect(tagsContent).toBeDefined(); + }); + + it('should handle getData error', async () => { + getData.mockRejectedValue(new Error('Extract error')); + + try { + await buildTools(); + } catch (err) { + expect(err.message).toContain('Extract error'); + } + }); + + it('should handle convertTools error', async () => { + const mockExtractData = [{ name: 'tool1' }, { name: 'tool2' }]; + getData.mockResolvedValue(mockExtractData); + convertTools.mockRejectedValue(new Error('Convert error')); + + try { + await buildTools(); + } catch (err) { + expect(err.message).toContain('Convert error'); + } + }); + + it('should handle combineTools error', async () => { + const mockExtractData = [{ name: 'tool1' }, { name: 'tool2' }]; + const mockConvertedData = [{ id: 1, tool: 'tool1' }, { id: 2, tool: 'tool2' }]; + + getData.mockResolvedValue(mockExtractData); + convertTools.mockResolvedValue(mockConvertedData); + combineTools.mockRejectedValue(new Error('Combine Tools error')); + + try { + await buildTools(); + } catch (err) { + expect(err.message).toContain('Combine Tools error'); + } + }); + + + it('should handle file write errors', async () => { + const mockExtractData = [{ name: 'tool1' }, { name: 'tool2' }]; + const mockConvertedData = [{ id: 1, tool: 'tool1' }, { id: 2, tool: 'tool2' }]; + + getData.mockResolvedValue(mockExtractData); + convertTools.mockResolvedValue(mockConvertedData); + combineTools.mockResolvedValue(true); + + const invalidPath = '/invalid_dir/tools.json'; + + try { + await buildTools(invalidPath); + } catch (err) { + expect(err.message).toMatch(/ENOENT|EACCES/); + } + }); +}); From 23ba7b07311de26e7c6d2a4b04ce34c86b81f92c Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Sat, 21 Sep 2024 16:07:03 +0530 Subject: [PATCH 03/20] added tests for errors --- scripts/build-tools.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build-tools.js b/scripts/build-tools.js index 1809e6a8d8b..134d6114df7 100644 --- a/scripts/build-tools.js +++ b/scripts/build-tools.js @@ -24,6 +24,7 @@ const buildTools = async () => { } }; +/* istanbul ignore next */ if (require.main === module) { buildTools(); } From 94d388aa431e50a19cab9444313ea5db0b8ba11e Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Sat, 21 Sep 2024 16:28:49 +0530 Subject: [PATCH 04/20] build-tools tests added --- scripts/build-tools.js | 21 +++++++------ tests/build-tools.test.js | 64 +++++++++++++++++++++++++++------------ 2 files changed, 55 insertions(+), 30 deletions(-) diff --git a/scripts/build-tools.js b/scripts/build-tools.js index 134d6114df7..abd2790f62e 100644 --- a/scripts/build-tools.js +++ b/scripts/build-tools.js @@ -1,24 +1,20 @@ const { getData } = require('./tools/extract-tools-github'); const { convertTools } = require('./tools/tools-object'); const { combineTools } = require('./tools/combine-tools'); -const manualTools = require('../config/tools-manual.json') - const fs = require('fs'); const { resolve } = require('path'); -const toolsPath = resolve(__dirname, '../../config', 'tools.json') -const tagsPath = resolve(__dirname, '../../config', 'all-tags.json') -const automatedToolsPath = resolve(__dirname, '../config', 'tools-automated.json') - -const buildTools = async () => { +const buildTools = async (automatedToolsPath, manualToolsPath, toolsPath, tagsPath) => { try { let githubExtractData = await getData(); let automatedTools = await convertTools(githubExtractData); + fs.writeFileSync( automatedToolsPath, JSON.stringify(automatedTools, null, ' ') ); - await combineTools(automatedTools, manualTools, toolsPath, tagsPath); + + await combineTools(automatedTools, require(manualToolsPath), toolsPath, tagsPath); } catch (err) { throw new Error(`An error occurred while building tools: ${err.message}`); } @@ -26,7 +22,12 @@ const buildTools = async () => { /* istanbul ignore next */ if (require.main === module) { - buildTools(); + const automatedToolsPath = resolve(__dirname, '../config', 'tools-automated.json'); + const manualToolsPath = resolve(__dirname, '../config', 'tools-manual.json'); + const toolsPath = resolve(__dirname, '../../config', 'tools.json'); + const tagsPath = resolve(__dirname, '../../config', 'all-tags.json'); + + buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); } -module.exports = {buildTools} \ No newline at end of file +module.exports = { buildTools }; diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index 123671cc261..6b739a78e66 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -18,12 +18,40 @@ describe('buildTools', () => { beforeAll(() => { mkdirSync(testDir, { recursive: true }); - // Create a temporary tools-manual.json + + const tagsData = [ + { id: 1, name: 'tag1' }, + { id: 2, name: 'tag2' } + ]; + writeFileSync(tagsPath, JSON.stringify(tagsData)); + const manualTools = [ { id: 1, tool: 'manualTool1' }, { id: 2, tool: 'manualTool2' } ]; + const mockConvertedData = [ + { id: 1, tool: 'tool1' }, + { id: 2, tool: 'tool2' } + ]; + + writeFileSync(automatedToolsPath, JSON.stringify(mockConvertedData)); writeFileSync(manualToolsPath, JSON.stringify(manualTools)); + + const initialToolsData = [ + { + title: "API Tracker", + description: "Explore public AsyncAPI specifications.", + }, + { + title: "AsyncAPI Server API", + description: "Official tools for AsyncAPI.", + }, + { + title: "AsyncAPI Generator", + description: "Generate AsyncAPI documents effortlessly.", + }, + ]; + writeFileSync(toolsPath, JSON.stringify(initialToolsData)); }); afterAll(() => { @@ -42,60 +70,56 @@ describe('buildTools', () => { convertTools.mockResolvedValue(mockConvertedData); combineTools.mockResolvedValue(true); - await buildTools(); + await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); - // Check if the automated tools file is written const automatedToolsContent = readFileSync(automatedToolsPath, 'utf8'); expect(JSON.parse(automatedToolsContent)).toEqual(mockConvertedData); - // Check if combineTools is called with correct arguments - expect(combineTools).toHaveBeenCalledWith(mockConvertedData, JSON.parse(readFileSync(manualToolsPath, 'utf8')), toolsPath, tagsPath); + const manualToolsData = JSON.parse(readFileSync(manualToolsPath, 'utf8')); + const tagsData = JSON.parse(readFileSync(tagsPath, 'utf8')); + expect(combineTools).toHaveBeenCalledWith(mockConvertedData, manualToolsData, toolsPath, tagsPath); - // Check if tools and tags files are written const toolsContent = readFileSync(toolsPath, 'utf8'); - const tagsContent = readFileSync(tagsPath, 'utf8'); - expect(toolsContent).toBeDefined(); - expect(tagsContent).toBeDefined(); + expect(tagsData).toBeDefined(); }); it('should handle getData error', async () => { getData.mockRejectedValue(new Error('Extract error')); - + try { - await buildTools(); + await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); } catch (err) { expect(err.message).toContain('Extract error'); } }); - + it('should handle convertTools error', async () => { const mockExtractData = [{ name: 'tool1' }, { name: 'tool2' }]; getData.mockResolvedValue(mockExtractData); convertTools.mockRejectedValue(new Error('Convert error')); - + try { - await buildTools(); + await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); } catch (err) { expect(err.message).toContain('Convert error'); } }); - + it('should handle combineTools error', async () => { const mockExtractData = [{ name: 'tool1' }, { name: 'tool2' }]; const mockConvertedData = [{ id: 1, tool: 'tool1' }, { id: 2, tool: 'tool2' }]; - + getData.mockResolvedValue(mockExtractData); convertTools.mockResolvedValue(mockConvertedData); combineTools.mockRejectedValue(new Error('Combine Tools error')); - + try { - await buildTools(); + await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); } catch (err) { expect(err.message).toContain('Combine Tools error'); } }); - it('should handle file write errors', async () => { const mockExtractData = [{ name: 'tool1' }, { name: 'tool2' }]; @@ -108,7 +132,7 @@ describe('buildTools', () => { const invalidPath = '/invalid_dir/tools.json'; try { - await buildTools(invalidPath); + await buildTools(invalidPath, manualToolsPath, toolsPath, tagsPath); } catch (err) { expect(err.message).toMatch(/ENOENT|EACCES/); } From 2397e01205cf84d9b8623e97b1de56c69429951d Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Sat, 21 Sep 2024 16:33:42 +0530 Subject: [PATCH 05/20] testCache update --- tests/build-tools.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index 6b739a78e66..410b5ffe42d 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -10,7 +10,7 @@ jest.mock('../scripts/tools/tools-object'); jest.mock('../scripts/tools/combine-tools'); describe('buildTools', () => { - const testDir = resolve(__dirname, 'test_config'); + const testDir = resolve(__dirname, 'testCache'); const toolsPath = resolve(testDir, 'tools.json'); const tagsPath = resolve(testDir, 'all-tags.json'); const automatedToolsPath = resolve(testDir, 'tools-automated.json'); From 5e9da7008466a0b4309a7e300488610829b6e8c2 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Sat, 21 Sep 2024 16:56:23 +0530 Subject: [PATCH 06/20] fixtures updated --- tests/build-tools.test.js | 40 +++----------------------------- tests/fixtures/buildToolsData.js | 39 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 37 deletions(-) create mode 100644 tests/fixtures/buildToolsData.js diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index 410b5ffe42d..8180762bffe 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -4,13 +4,14 @@ const { getData } = require('../scripts/tools/extract-tools-github'); const { convertTools } = require('../scripts/tools/tools-object'); const { combineTools } = require('../scripts/tools/combine-tools'); const { buildTools } = require('../scripts/build-tools'); +const { tagsData, manualTools, mockConvertedData, initialToolsData, mockExtractData } = require('../tests/fixtures/buildToolsData'); jest.mock('../scripts/tools/extract-tools-github'); jest.mock('../scripts/tools/tools-object'); jest.mock('../scripts/tools/combine-tools'); describe('buildTools', () => { - const testDir = resolve(__dirname, 'testCache'); + const testDir = resolve(__dirname, 'test_config'); const toolsPath = resolve(testDir, 'tools.json'); const tagsPath = resolve(testDir, 'all-tags.json'); const automatedToolsPath = resolve(testDir, 'tools-automated.json'); @@ -19,38 +20,9 @@ describe('buildTools', () => { beforeAll(() => { mkdirSync(testDir, { recursive: true }); - const tagsData = [ - { id: 1, name: 'tag1' }, - { id: 2, name: 'tag2' } - ]; writeFileSync(tagsPath, JSON.stringify(tagsData)); - - const manualTools = [ - { id: 1, tool: 'manualTool1' }, - { id: 2, tool: 'manualTool2' } - ]; - const mockConvertedData = [ - { id: 1, tool: 'tool1' }, - { id: 2, tool: 'tool2' } - ]; - writeFileSync(automatedToolsPath, JSON.stringify(mockConvertedData)); writeFileSync(manualToolsPath, JSON.stringify(manualTools)); - - const initialToolsData = [ - { - title: "API Tracker", - description: "Explore public AsyncAPI specifications.", - }, - { - title: "AsyncAPI Server API", - description: "Official tools for AsyncAPI.", - }, - { - title: "AsyncAPI Generator", - description: "Generate AsyncAPI documents effortlessly.", - }, - ]; writeFileSync(toolsPath, JSON.stringify(initialToolsData)); }); @@ -63,8 +35,6 @@ describe('buildTools', () => { }); it('should extract, convert, combine tools, and write to file', async () => { - const mockExtractData = [{ name: 'tool1' }, { name: 'tool2' }]; - const mockConvertedData = [{ id: 1, tool: 'tool1' }, { id: 2, tool: 'tool2' }]; getData.mockResolvedValue(mockExtractData); convertTools.mockResolvedValue(mockConvertedData); @@ -95,7 +65,7 @@ describe('buildTools', () => { }); it('should handle convertTools error', async () => { - const mockExtractData = [{ name: 'tool1' }, { name: 'tool2' }]; + getData.mockResolvedValue(mockExtractData); convertTools.mockRejectedValue(new Error('Convert error')); @@ -107,8 +77,6 @@ describe('buildTools', () => { }); it('should handle combineTools error', async () => { - const mockExtractData = [{ name: 'tool1' }, { name: 'tool2' }]; - const mockConvertedData = [{ id: 1, tool: 'tool1' }, { id: 2, tool: 'tool2' }]; getData.mockResolvedValue(mockExtractData); convertTools.mockResolvedValue(mockConvertedData); @@ -122,8 +90,6 @@ describe('buildTools', () => { }); it('should handle file write errors', async () => { - const mockExtractData = [{ name: 'tool1' }, { name: 'tool2' }]; - const mockConvertedData = [{ id: 1, tool: 'tool1' }, { id: 2, tool: 'tool2' }]; getData.mockResolvedValue(mockExtractData); convertTools.mockResolvedValue(mockConvertedData); diff --git a/tests/fixtures/buildToolsData.js b/tests/fixtures/buildToolsData.js new file mode 100644 index 00000000000..931854b033f --- /dev/null +++ b/tests/fixtures/buildToolsData.js @@ -0,0 +1,39 @@ +const tagsData = [ + { id: 1, name: 'tag1' }, + { id: 2, name: 'tag2' }, +]; + +const manualTools = [ + { id: 1, tool: 'manualTool1' }, + { id: 2, tool: 'manualTool2' }, +]; + +const mockConvertedData = [ + { id: 1, tool: 'tool1' }, + { id: 2, tool: 'tool2' }, +]; + +const initialToolsData = [ + { + title: "API Tracker", + description: "Explore public AsyncAPI specifications.", + }, + { + title: "AsyncAPI Server API", + description: "Official tools for AsyncAPI.", + }, + { + title: "AsyncAPI Generator", + description: "Generate AsyncAPI documents effortlessly.", + }, +]; + +const mockExtractData = [{ name: 'tool1' }, { name: 'tool2' }]; + +module.exports = { + tagsData, + manualTools, + mockConvertedData, + initialToolsData, + mockExtractData, +}; From c8588344fdb6d22552082a3222f19587ff1f1d67 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Sat, 21 Sep 2024 16:56:41 +0530 Subject: [PATCH 07/20] fixtures updated --- tests/build-tools.test.js | 70 --------------------------------------- 1 file changed, 70 deletions(-) diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index 8180762bffe..f87a44eae21 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -26,81 +26,11 @@ describe('buildTools', () => { writeFileSync(toolsPath, JSON.stringify(initialToolsData)); }); - afterAll(() => { - rmSync(testDir, { recursive: true, force: true }); - }); - beforeEach(() => { jest.clearAllMocks(); }); - it('should extract, convert, combine tools, and write to file', async () => { - - getData.mockResolvedValue(mockExtractData); - convertTools.mockResolvedValue(mockConvertedData); - combineTools.mockResolvedValue(true); - - await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); - - const automatedToolsContent = readFileSync(automatedToolsPath, 'utf8'); - expect(JSON.parse(automatedToolsContent)).toEqual(mockConvertedData); - - const manualToolsData = JSON.parse(readFileSync(manualToolsPath, 'utf8')); - const tagsData = JSON.parse(readFileSync(tagsPath, 'utf8')); - expect(combineTools).toHaveBeenCalledWith(mockConvertedData, manualToolsData, toolsPath, tagsPath); - - const toolsContent = readFileSync(toolsPath, 'utf8'); - expect(toolsContent).toBeDefined(); - expect(tagsData).toBeDefined(); - }); - - it('should handle getData error', async () => { - getData.mockRejectedValue(new Error('Extract error')); - - try { - await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); - } catch (err) { - expect(err.message).toContain('Extract error'); - } - }); - - it('should handle convertTools error', async () => { - - getData.mockResolvedValue(mockExtractData); - convertTools.mockRejectedValue(new Error('Convert error')); - - try { - await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); - } catch (err) { - expect(err.message).toContain('Convert error'); - } - }); - - it('should handle combineTools error', async () => { - - getData.mockResolvedValue(mockExtractData); - convertTools.mockResolvedValue(mockConvertedData); - combineTools.mockRejectedValue(new Error('Combine Tools error')); - - try { - await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); - } catch (err) { - expect(err.message).toContain('Combine Tools error'); - } - }); - it('should handle file write errors', async () => { - getData.mockResolvedValue(mockExtractData); - convertTools.mockResolvedValue(mockConvertedData); - combineTools.mockResolvedValue(true); - - const invalidPath = '/invalid_dir/tools.json'; - - try { - await buildTools(invalidPath, manualToolsPath, toolsPath, tagsPath); - } catch (err) { - expect(err.message).toMatch(/ENOENT|EACCES/); - } }); }); From c816f665c93ba42c0ea4e5eb3c04067ce64f2b5c Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Sat, 21 Sep 2024 16:57:59 +0530 Subject: [PATCH 08/20] fixtures updated --- tests/build-tools.test.js | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index f87a44eae21..8180762bffe 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -26,11 +26,81 @@ describe('buildTools', () => { writeFileSync(toolsPath, JSON.stringify(initialToolsData)); }); + afterAll(() => { + rmSync(testDir, { recursive: true, force: true }); + }); + beforeEach(() => { jest.clearAllMocks(); }); + it('should extract, convert, combine tools, and write to file', async () => { + + getData.mockResolvedValue(mockExtractData); + convertTools.mockResolvedValue(mockConvertedData); + combineTools.mockResolvedValue(true); + + await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); + + const automatedToolsContent = readFileSync(automatedToolsPath, 'utf8'); + expect(JSON.parse(automatedToolsContent)).toEqual(mockConvertedData); + + const manualToolsData = JSON.parse(readFileSync(manualToolsPath, 'utf8')); + const tagsData = JSON.parse(readFileSync(tagsPath, 'utf8')); + expect(combineTools).toHaveBeenCalledWith(mockConvertedData, manualToolsData, toolsPath, tagsPath); + + const toolsContent = readFileSync(toolsPath, 'utf8'); + expect(toolsContent).toBeDefined(); + expect(tagsData).toBeDefined(); + }); + + it('should handle getData error', async () => { + getData.mockRejectedValue(new Error('Extract error')); + + try { + await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); + } catch (err) { + expect(err.message).toContain('Extract error'); + } + }); + + it('should handle convertTools error', async () => { + + getData.mockResolvedValue(mockExtractData); + convertTools.mockRejectedValue(new Error('Convert error')); + + try { + await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); + } catch (err) { + expect(err.message).toContain('Convert error'); + } + }); + + it('should handle combineTools error', async () => { + + getData.mockResolvedValue(mockExtractData); + convertTools.mockResolvedValue(mockConvertedData); + combineTools.mockRejectedValue(new Error('Combine Tools error')); + + try { + await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); + } catch (err) { + expect(err.message).toContain('Combine Tools error'); + } + }); + it('should handle file write errors', async () => { + getData.mockResolvedValue(mockExtractData); + convertTools.mockResolvedValue(mockConvertedData); + combineTools.mockResolvedValue(true); + + const invalidPath = '/invalid_dir/tools.json'; + + try { + await buildTools(invalidPath, manualToolsPath, toolsPath, tagsPath); + } catch (err) { + expect(err.message).toMatch(/ENOENT|EACCES/); + } }); }); From 0c4126fa54714930794360a615183ee31a093e77 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Sat, 21 Sep 2024 17:15:58 +0530 Subject: [PATCH 09/20] fefe --- config/tools-automated.json | 874 +++++++++++++++++++++++++++++++++++- 1 file changed, 865 insertions(+), 9 deletions(-) diff --git a/config/tools-automated.json b/config/tools-automated.json index f312c1cf140..504b55f18f8 100644 --- a/config/tools-automated.json +++ b/config/tools-automated.json @@ -1,10 +1,866 @@ -[ - { - "id": 1, - "tool": "tool1" - }, - { - "id": 2, - "tool": "tool2" +{ + "APIs": { + "description": "The following is a list of APIs that expose functionality related to AsyncAPI.", + "toolsList": [ + { + "title": "AsyncAPI Server API", + "description": "Server API providing official AsyncAPI tools", + "links": { + "websiteUrl": "https://api.asyncapi.com/v1", + "docsUrl": "https://api.asyncapi.com/v1/docs", + "repoUrl": "https://github.com/asyncapi/server-api" + }, + "filters": { + "technology": [ + "Node.js", + "TypeScript" + ], + "categories": [ + "api" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + }, + { + "title": "SIO-AsyncAPI", + "description": "This is code-first approach to generate AsyncAPI specification from Socket.IO server.", + "links": { + "websiteUrl": "https://github.com/daler-rahimov/sio-asyncapi", + "docsUrl": "https://github.com/daler-rahimov/sio-asyncapi", + "repoUrl": "https://github.com/daler-rahimov/sio-asyncapi" + }, + "filters": { + "language": "Python", + "technology": [ + "Socket.IO", + "Flask" + ], + "categories": [ + "code-first", + "api" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + } + ] + }, + "Code-first tools": { + "description": "The following is a list of tools that generate AsyncAPI documents from your code.", + "toolsList": [ + { + "title": "AsyncAPI.Net", + "description": "The AsyncAPI.NET SDK contains a useful object model for AsyncAPI documents in .NET along with common serializers to extract raw OpenAPI JSON and YAML documents from the model.", + "links": { + "websiteUrl": "https://github.com/LEGO/AsyncAPI.NET/", + "repoUrl": "https://github.com/LEGO/AsyncAPI.NET" + }, + "filters": { + "language": "C#", + "technology": [ + ".NET", + "ASP.NET" + ], + "categories": [ + "converters", + "code-first", + "validator" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + }, + { + "title": "nestjs-asyncapi", + "description": "Utilize decorators to generate AsyncAPI document utilizing DTOs (similar to @nestjs/swagger) and a web UI.", + "links": { + "repoUrl": "https://github.com/flamewow/nestjs-asyncapi" + }, + "filters": { + "language": "Typescript", + "technology": [ + "Node.js", + "NestJS" + ], + "categories": [ + "code-first" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + }, + { + "title": "SIO-AsyncAPI", + "description": "This is code-first approach to generate AsyncAPI specification from Socket.IO server.", + "links": { + "websiteUrl": "https://github.com/daler-rahimov/sio-asyncapi", + "docsUrl": "https://github.com/daler-rahimov/sio-asyncapi", + "repoUrl": "https://github.com/daler-rahimov/sio-asyncapi" + }, + "filters": { + "language": "Python", + "technology": [ + "Socket.IO", + "Flask" + ], + "categories": [ + "code-first", + "api" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + }, + { + "title": "Zod Sockets", + "description": "Socket.IO solution with I/O validation and the ability to generate AsyncAPI specification and a contract for consumers.", + "links": { + "websiteUrl": "https://www.npmjs.com/package/zod-sockets", + "repoUrl": "https://github.com/RobinTail/zod-sockets" + }, + "filters": { + "language": "TypeScript", + "technology": [ + "Node.js", + "TypeScript" + ], + "categories": [ + "code-first", + "dsl", + "framework" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + } + ] + }, + "Code Generators": { + "description": "The following is a list of tools that generate code from an AsyncAPI document; not the other way around.", + "toolsList": [ + { + "title": "Golang AsyncAPI Code Generator", + "description": "Generate Go user and application boilerplate from AsyncAPI specifications. Can be called from `go generate` without requirements.\n", + "links": { + "repoUrl": "https://github.com/lerenn/asyncapi-codegen" + }, + "filters": { + "language": "golang", + "categories": [ + "code-generator" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + }, + { + "title": "ZenWave SDK", + "description": "DDD and API-First for Event-Driven Microservices", + "links": { + "websiteUrl": "https://zenwave360.github.io/", + "docsUrl": "https://zenwave360.github.io/zenwave-sdk/plugins/asyncapi-spring-cloud-streams3/", + "repoUrl": "https://github.com/zenwave360/zenwave-sdk" + }, + "filters": { + "language": "Java", + "technology": [ + "Maven", + "CLI", + "Spring Cloud Streams", + "JHipster JDL" + ], + "categories": [ + "code-generator", + "dsl", + "mocking-and-testing", + "cli" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + }, + { + "title": "AsyncAPI Modelina", + "description": "Generate payload models into Java, TypeScript, Go, etc, you name it, from AsyncAPI documents. This tool gives you full control over the models through high customization", + "links": { + "websiteUrl": "https://modelina.org", + "docsUrl": "https://github.com/asyncapi/modelina/tree/master/docs", + "repoUrl": "https://github.com/asyncapi/modelina" + }, + "filters": { + "language": "TypeScript", + "technology": [ + "React JS", + "Docker" + ], + "categories": [ + "code-generator" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + } + ] + }, + "Converters": { + "description": "The following is a list of tools that do not yet belong to any specific category but are also useful for the community.", + "toolsList": [ + { + "title": "AsyncAPI.Net", + "description": "The AsyncAPI.NET SDK contains a useful object model for AsyncAPI documents in .NET along with common serializers to extract raw OpenAPI JSON and YAML documents from the model.", + "links": { + "websiteUrl": "https://github.com/LEGO/AsyncAPI.NET/", + "repoUrl": "https://github.com/LEGO/AsyncAPI.NET" + }, + "filters": { + "language": "C#", + "technology": [ + ".NET", + "ASP.NET" + ], + "categories": [ + "converters", + "code-first", + "validator" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + } + ] + }, + "Directories": { + "description": "The following is a list of directories that index public AsyncAPI documents.", + "toolsList": [] + }, + "Documentation Generators": { + "description": "The following is a list of tools that generate human-readable documentation from an AsyncAPI document.", + "toolsList": [] + }, + "Editors": { + "description": "The following is a list of editors or related tools that allow editing of AsyncAPI document.", + "toolsList": [ + { + "title": "AsyncAPI Studio", + "description": "Visually design your AsyncAPI files and event-driven architecture.", + "links": { + "websiteUrl": "https://studio.asyncapi.com", + "repoUrl": "https://github.com/asyncapi/studio" + }, + "filters": { + "technology": [ + "React JS", + "TypeScript" + ], + "categories": [ + "editor" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + } + ] + }, + "UI components": { + "description": "The following is a list of UI components to view AsyncAPI documents.", + "toolsList": [ + { + "title": "AsyncAPI React component", + "description": "React component for rendering documentation from your specification in real-time in the browser. It also provides a WebComponent and bundle for Angular and Vue", + "links": { + "repoUrl": "https://github.com/asyncapi/asyncapi-react" + }, + "filters": { + "language": "TypeScript", + "technology": [ + "React js", + "WebComponents" + ], + "categories": [ + "ui-component" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + } + ] + }, + "DSL": { + "description": "Writing YAML by hand is no fun, and maybe you don't want a GUI, so use a Domain Specific Language to write AsyncAPI in your language of choice.", + "toolsList": [ + { + "title": "ZenWave SDK", + "description": "DDD and API-First for Event-Driven Microservices", + "links": { + "websiteUrl": "https://zenwave360.github.io/", + "docsUrl": "https://zenwave360.github.io/zenwave-sdk/plugins/asyncapi-spring-cloud-streams3/", + "repoUrl": "https://github.com/zenwave360/zenwave-sdk" + }, + "filters": { + "language": "Java", + "technology": [ + "Maven", + "CLI", + "Spring Cloud Streams", + "JHipster JDL" + ], + "categories": [ + "code-generator", + "dsl", + "mocking-and-testing", + "cli" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + }, + { + "title": "Zod Sockets", + "description": "Socket.IO solution with I/O validation and the ability to generate AsyncAPI specification and a contract for consumers.", + "links": { + "websiteUrl": "https://www.npmjs.com/package/zod-sockets", + "repoUrl": "https://github.com/RobinTail/zod-sockets" + }, + "filters": { + "language": "TypeScript", + "technology": [ + "Node.js", + "TypeScript" + ], + "categories": [ + "code-first", + "dsl", + "framework" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + } + ] + }, + "Frameworks": { + "description": "The following is a list of API/application frameworks that make use of AsyncAPI.", + "toolsList": [ + { + "title": "Zod Sockets", + "description": "Socket.IO solution with I/O validation and the ability to generate AsyncAPI specification and a contract for consumers.", + "links": { + "websiteUrl": "https://www.npmjs.com/package/zod-sockets", + "repoUrl": "https://github.com/RobinTail/zod-sockets" + }, + "filters": { + "language": "TypeScript", + "technology": [ + "Node.js", + "TypeScript" + ], + "categories": [ + "code-first", + "dsl", + "framework" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + } + ] + }, + "GitHub Actions": { + "description": "The following is a list of GitHub Actions that you can use in your workflows", + "toolsList": [ + { + "title": "GitHub Action for Generator", + "description": null, + "links": { + "repoUrl": "https://github.com/actions-marketplace-validations/asyncapi_github-action-for-generator" + }, + "filters": { + "technology": [ + "AsyncAPI Generator" + ], + "categories": [ + "github-action" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + }, + { + "title": "GitHub Action for CLI", + "description": "GitHub Action with generator, validator, converter and others - all in one for your AsyncAPI documents with AsyncAPI CLI as backbone", + "links": { + "repoUrl": "https://github.com/asyncapi/github-action-for-cli" + }, + "filters": { + "technology": [ + "AsyncAPI CLI" + ], + "categories": [ + "github-action" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + } + ] + }, + "Mocking and Testing": { + "description": "The tools below take specification documents as input, then publish fake messages to broker destinations for simulation purposes. They may also check that publisher messages are compliant with schemas.", + "toolsList": [ + { + "title": "Specmatic", + "description": "An API contract testing tool that helps ensure the correctness APIs by automatically generating test cases and verifying them against the API spec. It simplifies the process of testing APIs and reduces the likelihood of bugs and compatibility issues.", + "links": { + "websiteUrl": "https://specmatic.io", + "docsUrl": "https://specmatic.io/documentation/", + "repoUrl": "https://github.com/znsio/specmatic" + }, + "filters": { + "language": "kotlin", + "technology": [ + "maven" + ], + "categories": [ + "mocking-and-testing" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + }, + { + "title": "ZenWave SDK", + "description": "DDD and API-First for Event-Driven Microservices", + "links": { + "websiteUrl": "https://zenwave360.github.io/", + "docsUrl": "https://zenwave360.github.io/zenwave-sdk/plugins/asyncapi-spring-cloud-streams3/", + "repoUrl": "https://github.com/zenwave360/zenwave-sdk" + }, + "filters": { + "language": "Java", + "technology": [ + "Maven", + "CLI", + "Spring Cloud Streams", + "JHipster JDL" + ], + "categories": [ + "code-generator", + "dsl", + "mocking-and-testing", + "cli" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + } + ] + }, + "Validators": { + "description": "The following is a list of tools that validate AsyncAPI documents.", + "toolsList": [ + { + "title": "AsyncAPI.Net", + "description": "The AsyncAPI.NET SDK contains a useful object model for AsyncAPI documents in .NET along with common serializers to extract raw OpenAPI JSON and YAML documents from the model.", + "links": { + "websiteUrl": "https://github.com/LEGO/AsyncAPI.NET/", + "repoUrl": "https://github.com/LEGO/AsyncAPI.NET" + }, + "filters": { + "language": "C#", + "technology": [ + ".NET", + "ASP.NET" + ], + "categories": [ + "converters", + "code-first", + "validator" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + }, + { + "title": "AsyncAPI Validation", + "description": "Message validation package for YAML and JSON AsyncAPI documents.", + "links": { + "repoUrl": "https://github.com/Elhebert/asyncapi-validation" + }, + "filters": { + "language": "TypeScript", + "technology": [ + "Node.js" + ], + "categories": [ + "validator" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + } + ] + }, + "Compare tools": { + "description": "The following is a list of tools that compare AsyncAPI documents.", + "toolsList": [ + { + "title": "jasyncapicmp", + "description": "Tool for comparing two AsyncAPI versions and evaluating compatibility.", + "links": { + "websiteUrl": "https://siom79.github.io/jasyncapicmp/", + "docsUrl": "https://github.com/siom79/jasyncapicmp", + "repoUrl": "https://github.com/siom79/jasyncapicmp" + }, + "filters": { + "language": "Java", + "technology": [ + "Maven" + ], + "categories": [ + "compare-tool" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + }, + { + "title": "AsyncAPI Diff", + "description": "Diff is a library that compares two AsyncAPI Documents and provides information about the differences by pointing out explicitly information like breaking changes.", + "links": { + "repoUrl": "https://github.com/asyncapi/diff" + }, + "filters": { + "language": "TypeScript", + "technology": [ + "TypeScript" + ], + "categories": [ + "compare-tool" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + } + ] + }, + "CLIs": { + "description": "The following is a list of tools that you can work with in terminal or do some CI/CD automation.", + "toolsList": [ + { + "title": "AsyncAPI CLI", + "description": "One CLI to rule them all. \nThis is a CLI that aims to integrate all AsyncAPI tools that you need while AsyncAPI document development and maintainance. \nYou can use it to generate docs or code, validate AsyncAPI document and event create new documents.\n", + "links": { + "websiteUrl": "https://www.asyncapi.com/tools/cli", + "repoUrl": "https://github.com/asyncapi/cli" + }, + "filters": { + "technology": [ + "TypeScript" + ], + "categories": [ + "others", + "cli" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + }, + { + "title": "ZenWave SDK", + "description": "DDD and API-First for Event-Driven Microservices", + "links": { + "websiteUrl": "https://zenwave360.github.io/", + "docsUrl": "https://zenwave360.github.io/zenwave-sdk/plugins/asyncapi-spring-cloud-streams3/", + "repoUrl": "https://github.com/zenwave360/zenwave-sdk" + }, + "filters": { + "language": "Java", + "technology": [ + "Maven", + "CLI", + "Spring Cloud Streams", + "JHipster JDL" + ], + "categories": [ + "code-generator", + "dsl", + "mocking-and-testing", + "cli" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + }, + { + "title": "AsyncAPI CLI", + "description": "One CLI to rule them all. \nThis is a CLI that aims to integrate all AsyncAPI tools that you need while AsyncAPI document development and maintainance. \nYou can use it to generate docs or code, validate AsyncAPI document and event create new documents.\n", + "links": { + "websiteUrl": "https://www.asyncapi.com/tools/cli", + "repoUrl": "https://github.com/hkirat/asyncapi-fork" + }, + "filters": { + "technology": [ + "TypeScript" + ], + "categories": [ + "others", + "cli" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + } + ] + }, + "Bundlers": { + "description": "The following is a list of tools that you can work with to bundle AsyncAPI documents.", + "toolsList": [ + { + "title": "AsyncAPI Bundler", + "description": "Combine multiple AsyncAPI specification files into one.", + "links": { + "repoUrl": "https://github.com/asyncapi/bundler" + }, + "filters": { + "language": "TypeScript", + "technology": [ + "TypeScript" + ], + "categories": [ + "bundler" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + } + ] + }, + "IDE Extensions": { + "description": "The following is a list of extensions for different IDEs like VSCode, IntelliJ IDEA and others", + "toolsList": [ + { + "title": "jAsyncAPI - IDEA plugin", + "description": "Idea plugin for the java-asyncapi - Helps to edit and validate AsyncAPI schemas.", + "links": { + "websiteUrl": "https://plugins.jetbrains.com/plugin/15673-asyncapi", + "docsUrl": "https://github.com/asyncapi/jasyncapi-idea-plugin#usage", + "repoUrl": "https://github.com/asyncapi/jasyncapi-idea-plugin" + }, + "filters": { + "language": "Kotlin", + "technology": [ + "JetBrains", + "IntelliJ IDEA" + ], + "categories": [ + "ide-extension" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + }, + { + "title": "asyncapi-preview", + "description": "VSCode extension that enables you to:\n - Preview documentation generated using you AsyncAPI document. It uses AsyncAPI React component under the hood,\n - Create AsyncAPI documents faster using SmartPaste functionality\n", + "links": { + "repoUrl": "https://github.com/asyncapi/vs-asyncapi-preview" + }, + "filters": { + "technology": [ + "VSCode", + "SmartPaste" + ], + "categories": [ + "ide-extension" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + }, + { + "title": "asyncapi-preview", + "description": "VSCode extension that enables you to:\n - Preview documentation generated using you AsyncAPI document. It uses AsyncAPI React component under the hood,\n - Create AsyncAPI documents faster using SmartPaste functionality\n", + "links": { + "repoUrl": "https://github.com/Savio629/testing2" + }, + "filters": { + "technology": [ + "VSCode", + "SmartPaste" + ], + "categories": [ + "ide-extension" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + } + ] + }, + "AsyncAPI Generator Templates": { + "description": "The following is a list of templates compatible with AsyncAPI Generator. You can use them to generate apps, clients or documentation from your AsyncAPI documents.", + "toolsList": [ + { + "title": "Node.js Websockets Template", + "description": "Node.js WebSockets template for the AsyncAPI Generator. It showcases how from a single AsyncAPI document you can generate a server and a client at the same time.", + "links": { + "repoUrl": "https://github.com/asyncapi/nodejs-ws-template" + }, + "filters": { + "language": "javascript", + "technology": [ + "Node.js" + ], + "categories": [ + "generator-template" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + }, + { + "title": "Java Template", + "description": "Java template for the AsyncAPI Generator", + "links": { + "repoUrl": "https://github.com/asyncapi/java-template" + }, + "filters": { + "language": [ + "javascript" + ], + "technology": [ + "Java" + ], + "categories": [ + "generator-template" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + }, + { + "title": "Java Spring Cloud Stream Template", + "description": "Java Spring Cloud Stream template for the AsyncAPI Generator", + "links": { + "repoUrl": "https://github.com/asyncapi/java-spring-cloud-stream-template" + }, + "filters": { + "language": [ + "javascript" + ], + "technology": [ + "Spring Cloud Streams", + "Maven" + ], + "categories": [ + "generator-template" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + }, + { + "title": "Node.js Multiprotocol Template", + "description": "This template generates a server using your AsyncAPI document. It supports multiple different protocols, like Kafka or MQTT. It is designed in the way that generated code is a library and with it's API you can start the server, send messages or register a middleware for listening incoming messages. Runtime message validation included.", + "links": { + "repoUrl": "https://github.com/asyncapi/nodejs-template" + }, + "filters": { + "language": "javascript", + "technology": [ + "Node.js" + ], + "categories": [ + "generator-template" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + }, + { + "title": "HTML Template", + "description": "HTML template for AsyncAPI Generator. Use it to generate a static docs. It is using AsyncAPI React component under the hood.", + "links": { + "repoUrl": "https://github.com/asyncapi/html-template" + }, + "filters": { + "language": "javascript", + "technology": [ + "HTML" + ], + "categories": [ + "generator-template" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + }, + { + "title": "Java Spring Template", + "description": "Java Spring template for the AsyncAPI Generator", + "links": { + "repoUrl": "https://github.com/asyncapi/java-spring-template" + }, + "filters": { + "language": [ + "javascript" + ], + "technology": [ + "Springboot", + "Maven", + "Gradle" + ], + "categories": [ + "generator-template" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + } + ] + }, + "Others": { + "description": "The following is a list of tools that comes under Other category.", + "toolsList": [ + { + "title": "AsyncAPI CLI", + "description": "One CLI to rule them all. \nThis is a CLI that aims to integrate all AsyncAPI tools that you need while AsyncAPI document development and maintainance. \nYou can use it to generate docs or code, validate AsyncAPI document and event create new documents.\n", + "links": { + "websiteUrl": "https://www.asyncapi.com/tools/cli", + "repoUrl": "https://github.com/asyncapi/cli" + }, + "filters": { + "technology": [ + "TypeScript" + ], + "categories": [ + "others", + "cli" + ], + "hasCommercial": false, + "isAsyncAPIOwner": true + } + }, + { + "title": "AsyncAPI CLI", + "description": "One CLI to rule them all. \nThis is a CLI that aims to integrate all AsyncAPI tools that you need while AsyncAPI document development and maintainance. \nYou can use it to generate docs or code, validate AsyncAPI document and event create new documents.\n", + "links": { + "websiteUrl": "https://www.asyncapi.com/tools/cli", + "repoUrl": "https://github.com/hkirat/asyncapi-fork" + }, + "filters": { + "technology": [ + "TypeScript" + ], + "categories": [ + "others", + "cli" + ], + "hasCommercial": false, + "isAsyncAPIOwner": false + } + } + ] } -] \ No newline at end of file +} \ No newline at end of file From 8a9ba652bf24e388e2981594fd172b94dd76d84b Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Mon, 23 Sep 2024 18:30:50 +0530 Subject: [PATCH 10/20] paths update --- scripts/build-tools.js | 4 ++-- scripts/tools/combine-tools.js | 13 +++---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/scripts/build-tools.js b/scripts/build-tools.js index abd2790f62e..abb9fd09594 100644 --- a/scripts/build-tools.js +++ b/scripts/build-tools.js @@ -24,8 +24,8 @@ const buildTools = async (automatedToolsPath, manualToolsPath, toolsPath, tagsPa if (require.main === module) { const automatedToolsPath = resolve(__dirname, '../config', 'tools-automated.json'); const manualToolsPath = resolve(__dirname, '../config', 'tools-manual.json'); - const toolsPath = resolve(__dirname, '../../config', 'tools.json'); - const tagsPath = resolve(__dirname, '../../config', 'all-tags.json'); + const toolsPath = resolve(__dirname, '../config', 'tools.json'); + const tagsPath = resolve(__dirname, '../config', 'all-tags.json'); buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); } diff --git a/scripts/tools/combine-tools.js b/scripts/tools/combine-tools.js index f929f00095b..602262428fa 100644 --- a/scripts/tools/combine-tools.js +++ b/scripts/tools/combine-tools.js @@ -5,7 +5,6 @@ const fs = require('fs') const schema = require("./tools-schema.json"); const Ajv = require("ajv") const addFormats = require("ajv-formats") -const { resolve } = require('path'); const Fuse = require("fuse.js"); const ajv = new Ajv() addFormats(ajv, ["uri"]) @@ -106,7 +105,7 @@ const getFinalTool = async (toolObject) => { // Combine the automated tools and manual tools list into single JSON object file, and // lists down all the language and technology tags in one JSON file. -const combineTools = async (automatedTools, manualTools) => { +const combineTools = async (automatedTools, manualTools, toolsPath, tagsPath) => { for (const key in automatedTools) { let finalToolsList = []; if (automatedTools[key].toolsList.length) { @@ -136,14 +135,8 @@ const combineTools = async (automatedTools, manualTools) => { finalToolsList.sort((tool, anotherTool) => tool.title.localeCompare(anotherTool.title)); finalTools[key].toolsList = finalToolsList } - fs.writeFileSync( - resolve(__dirname, '../../config', 'tools.json'), - JSON.stringify(finalTools) - ); - fs.writeFileSync( - resolve(__dirname, '../../config', 'all-tags.json'), - JSON.stringify({ languages: languageList, technologies: technologyList }), - ) + fs.writeFileSync(toolsPath,JSON.stringify(finalTools)); + fs.writeFileSync(tagsPath,JSON.stringify({ languages: languageList, technologies: technologyList }),) } module.exports = { combineTools } \ No newline at end of file From 11a5d05fe7cfccf1fa567ea4c8741409811742c0 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Wed, 25 Sep 2024 18:15:22 +0530 Subject: [PATCH 11/20] added expect statements --- tests/build-tools.test.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index 8180762bffe..d273ad9904e 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -47,11 +47,15 @@ describe('buildTools', () => { const manualToolsData = JSON.parse(readFileSync(manualToolsPath, 'utf8')); const tagsData = JSON.parse(readFileSync(tagsPath, 'utf8')); - expect(combineTools).toHaveBeenCalledWith(mockConvertedData, manualToolsData, toolsPath, tagsPath); - + const toolsData = JSON.parse(readFileSync(toolsPath, 'utf8')); const toolsContent = readFileSync(toolsPath, 'utf8'); + + expect(combineTools).toHaveBeenCalledWith(mockConvertedData, manualToolsData, toolsPath, tagsPath); + expect(toolsContent).toBeDefined(); expect(tagsData).toBeDefined(); + expect(toolsData).toEqual(initialToolsData); + expect(tagsData).toEqual(tagsData); }); it('should handle getData error', async () => { From 26a4be26cc5eea203240f13be6192db02a9d2db8 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Thu, 26 Sep 2024 14:07:47 +0530 Subject: [PATCH 12/20] tests updated --- tests/build-tools.test.js | 40 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index d273ad9904e..dbea46c2965 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -20,10 +20,7 @@ describe('buildTools', () => { beforeAll(() => { mkdirSync(testDir, { recursive: true }); - writeFileSync(tagsPath, JSON.stringify(tagsData)); - writeFileSync(automatedToolsPath, JSON.stringify(mockConvertedData)); writeFileSync(manualToolsPath, JSON.stringify(manualTools)); - writeFileSync(toolsPath, JSON.stringify(initialToolsData)); }); afterAll(() => { @@ -35,10 +32,21 @@ describe('buildTools', () => { }); it('should extract, convert, combine tools, and write to file', async () => { - - getData.mockResolvedValue(mockExtractData); - convertTools.mockResolvedValue(mockConvertedData); - combineTools.mockResolvedValue(true); + getData.mockImplementation(async () => { + writeFileSync(automatedToolsPath, JSON.stringify(mockExtractData)); + return mockExtractData; + }); + + convertTools.mockImplementation(async () => { + writeFileSync(automatedToolsPath, JSON.stringify(mockConvertedData)); + return mockConvertedData; + }); + + combineTools.mockImplementation(async () => { + writeFileSync(toolsPath, JSON.stringify(initialToolsData)); + writeFileSync(tagsPath, JSON.stringify(tagsData)); + return true; + }); await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); @@ -46,16 +54,13 @@ describe('buildTools', () => { expect(JSON.parse(automatedToolsContent)).toEqual(mockConvertedData); const manualToolsData = JSON.parse(readFileSync(manualToolsPath, 'utf8')); - const tagsData = JSON.parse(readFileSync(tagsPath, 'utf8')); - const toolsData = JSON.parse(readFileSync(toolsPath, 'utf8')); - const toolsContent = readFileSync(toolsPath, 'utf8'); - + const tagsFileData = JSON.parse(readFileSync(tagsPath, 'utf8')); + const toolsFileData = JSON.parse(readFileSync(toolsPath, 'utf8')); + expect(combineTools).toHaveBeenCalledWith(mockConvertedData, manualToolsData, toolsPath, tagsPath); - - expect(toolsContent).toBeDefined(); - expect(tagsData).toBeDefined(); - expect(toolsData).toEqual(initialToolsData); - expect(tagsData).toEqual(tagsData); + + expect(toolsFileData).toEqual(initialToolsData); + expect(tagsFileData).toEqual(tagsData); }); it('should handle getData error', async () => { @@ -69,7 +74,6 @@ describe('buildTools', () => { }); it('should handle convertTools error', async () => { - getData.mockResolvedValue(mockExtractData); convertTools.mockRejectedValue(new Error('Convert error')); @@ -81,7 +85,6 @@ describe('buildTools', () => { }); it('should handle combineTools error', async () => { - getData.mockResolvedValue(mockExtractData); convertTools.mockResolvedValue(mockConvertedData); combineTools.mockRejectedValue(new Error('Combine Tools error')); @@ -94,7 +97,6 @@ describe('buildTools', () => { }); it('should handle file write errors', async () => { - getData.mockResolvedValue(mockExtractData); convertTools.mockResolvedValue(mockConvertedData); combineTools.mockResolvedValue(true); From b744e49432103e47c2777b1bef62d26e81b67db8 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Wed, 2 Oct 2024 14:28:27 +0530 Subject: [PATCH 13/20] fef --- tests/build-tools.test.js | 72 ++++++++----------- tests/fixtures/buildToolsData.js | 117 +++++++++++++++++++++++++------ 2 files changed, 122 insertions(+), 67 deletions(-) diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index dbea46c2965..a069f1a8d83 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -1,14 +1,10 @@ -const { readFileSync, rmSync, mkdirSync, writeFileSync } = require('fs'); +const axios = require('axios'); const { resolve } = require('path'); -const { getData } = require('../scripts/tools/extract-tools-github'); -const { convertTools } = require('../scripts/tools/tools-object'); -const { combineTools } = require('../scripts/tools/combine-tools'); const { buildTools } = require('../scripts/build-tools'); const { tagsData, manualTools, mockConvertedData, initialToolsData, mockExtractData } = require('../tests/fixtures/buildToolsData'); +const fs = require('fs'); -jest.mock('../scripts/tools/extract-tools-github'); -jest.mock('../scripts/tools/tools-object'); -jest.mock('../scripts/tools/combine-tools'); +jest.mock('axios'); describe('buildTools', () => { const testDir = resolve(__dirname, 'test_config'); @@ -16,55 +12,43 @@ describe('buildTools', () => { const tagsPath = resolve(testDir, 'all-tags.json'); const automatedToolsPath = resolve(testDir, 'tools-automated.json'); const manualToolsPath = resolve(testDir, 'tools-manual.json'); + console.log(testDir, toolsPath, tagsPath, automatedToolsPath, manualToolsPath); beforeAll(() => { - mkdirSync(testDir, { recursive: true }); - - writeFileSync(manualToolsPath, JSON.stringify(manualTools)); + fs.mkdirSync(testDir, { recursive: true }); + fs.writeFileSync(manualToolsPath, JSON.stringify(manualTools)); }); - afterAll(() => { - rmSync(testDir, { recursive: true, force: true }); - }); + // afterAll(() => { + // fs.rmSync(testDir, { recursive: true, force: true }); + // }); beforeEach(() => { jest.clearAllMocks(); }); it('should extract, convert, combine tools, and write to file', async () => { - getData.mockImplementation(async () => { - writeFileSync(automatedToolsPath, JSON.stringify(mockExtractData)); - return mockExtractData; - }); - - convertTools.mockImplementation(async () => { - writeFileSync(automatedToolsPath, JSON.stringify(mockConvertedData)); - return mockConvertedData; - }); - - combineTools.mockImplementation(async () => { - writeFileSync(toolsPath, JSON.stringify(initialToolsData)); - writeFileSync(tagsPath, JSON.stringify(tagsData)); - return true; - }); + axios.get.mockResolvedValue({ data: mockExtractData }); await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); - const automatedToolsContent = readFileSync(automatedToolsPath, 'utf8'); - expect(JSON.parse(automatedToolsContent)).toEqual(mockConvertedData); - - const manualToolsData = JSON.parse(readFileSync(manualToolsPath, 'utf8')); - const tagsFileData = JSON.parse(readFileSync(tagsPath, 'utf8')); - const toolsFileData = JSON.parse(readFileSync(toolsPath, 'utf8')); + const automatedToolsContent = JSON.parse(fs.readFileSync(automatedToolsPath, 'utf8')); + + // Check important properties + expect(Object.keys(automatedToolsContent)).toEqual(Object.keys(mockConvertedData)); + expect(automatedToolsContent["Category1"].description).toEqual(mockConvertedData["Category1"].description); + expect(automatedToolsContent["Category2"].description).toEqual(mockConvertedData["Category2"].description); - expect(combineTools).toHaveBeenCalledWith(mockConvertedData, manualToolsData, toolsPath, tagsPath); + const manualToolsData = JSON.parse(fs.readFileSync(manualToolsPath, 'utf8')); + const tagsFileData = JSON.parse(fs.readFileSync(tagsPath, 'utf8')); + const toolsFileData = JSON.parse(fs.readFileSync(toolsPath, 'utf8')); expect(toolsFileData).toEqual(initialToolsData); expect(tagsFileData).toEqual(tagsData); }); it('should handle getData error', async () => { - getData.mockRejectedValue(new Error('Extract error')); + axios.get.mockRejectedValue(new Error('Extract error')); try { await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); @@ -74,8 +58,8 @@ describe('buildTools', () => { }); it('should handle convertTools error', async () => { - getData.mockResolvedValue(mockExtractData); - convertTools.mockRejectedValue(new Error('Convert error')); + axios.get.mockResolvedValue({ data: mockExtractData }); + jest.spyOn(require('../scripts/tools/tools-object'), 'convertTools').mockRejectedValue(new Error('Convert error')); try { await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); @@ -85,9 +69,9 @@ describe('buildTools', () => { }); it('should handle combineTools error', async () => { - getData.mockResolvedValue(mockExtractData); - convertTools.mockResolvedValue(mockConvertedData); - combineTools.mockRejectedValue(new Error('Combine Tools error')); + axios.get.mockResolvedValue({ data: mockExtractData }); + jest.spyOn(require('../scripts/tools/tools-object'), 'convertTools').mockResolvedValue(mockConvertedData); + jest.spyOn(require('../scripts/tools/combine-tools'), 'combineTools').mockRejectedValue(new Error('Combine Tools error')); try { await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); @@ -97,9 +81,9 @@ describe('buildTools', () => { }); it('should handle file write errors', async () => { - getData.mockResolvedValue(mockExtractData); - convertTools.mockResolvedValue(mockConvertedData); - combineTools.mockResolvedValue(true); + axios.get.mockResolvedValue({ data: mockExtractData }); + jest.spyOn(require('../scripts/tools/tools-object'), 'convertTools').mockResolvedValue(mockConvertedData); + jest.spyOn(require('../scripts/tools/combine-tools'), 'combineTools').mockResolvedValue(true); const invalidPath = '/invalid_dir/tools.json'; diff --git a/tests/fixtures/buildToolsData.js b/tests/fixtures/buildToolsData.js index 931854b033f..4c5996f95bf 100644 --- a/tests/fixtures/buildToolsData.js +++ b/tests/fixtures/buildToolsData.js @@ -1,34 +1,105 @@ -const tagsData = [ - { id: 1, name: 'tag1' }, - { id: 2, name: 'tag2' }, -]; +const tagsData = { + languages: [ + { name: 'JavaScript', color: 'bg-[#f1e05a]', borderColor: 'border-[#f1e05a]' }, + { name: 'Python', color: 'bg-[#3572A5]', borderColor: 'border-[#3572A5]' }, + ], + technologies: [ + { name: 'React', color: 'bg-[#61dafb]', borderColor: 'border-[#61dafb]' }, + { name: 'Node.js', color: 'bg-[#68a063]', borderColor: 'border-[#68a063]' }, + ], +}; const manualTools = [ - { id: 1, tool: 'manualTool1' }, - { id: 2, tool: 'manualTool2' }, -]; - -const mockConvertedData = [ - { id: 1, tool: 'tool1' }, - { id: 2, tool: 'tool2' }, -]; - -const initialToolsData = [ - { - title: "API Tracker", - description: "Explore public AsyncAPI specifications.", - }, { - title: "AsyncAPI Server API", - description: "Official tools for AsyncAPI.", + title: "Manual Tool 1", + description: "Description for manual tool 1", + links: { repoUrl: "https://github.com/manual/tool1" }, + filters: { categories: ["Category1"], language: "JavaScript", technology: ["React"] } }, { - title: "AsyncAPI Generator", - description: "Generate AsyncAPI documents effortlessly.", + title: "Manual Tool 2", + description: "Description for manual tool 2", + links: { repoUrl: "https://github.com/manual/tool2" }, + filters: { categories: ["Category2"], language: "Python", technology: ["Node.js"] } }, ]; -const mockExtractData = [{ name: 'tool1' }, { name: 'tool2' }]; +const mockConvertedData = { + "Category1": { + description: "Description for Category1", + toolsList: [ + { + title: "Tool 1", + description: "Description for tool 1", + links: { repoUrl: "https://github.com/tool1" }, + filters: { categories: ["Category1"], language: "JavaScript", technology: ["React"] } + } + ] + }, + "Category2": { + description: "Description for Category2", + toolsList: [ + { + title: "Tool 2", + description: "Description for tool 2", + links: { repoUrl: "https://github.com/tool2" }, + filters: { categories: ["Category2"], language: "Python", technology: ["Node.js"] } + } + ] + } +}; + +const initialToolsData = { + "Category1": { + description: "Description for Category1", + toolsList: [ + { + title: "Tool 1", + description: "Description for tool 1", + links: { repoUrl: "https://github.com/tool1" }, + filters: { categories: ["Category1"], language: "JavaScript", technology: ["React"] } + } + ] + }, + "Category2": { + description: "Description for Category2", + toolsList: [ + { + title: "Tool 2", + description: "Description for tool 2", + links: { repoUrl: "https://github.com/tool2" }, + filters: { categories: ["Category2"], language: "Python", technology: ["Node.js"] } + } + ] + } +}; + +const mockExtractData = { + items: [ + { + name: '.asyncapi-tool', + url: 'https://api.github.com/repositories/123456/contents/.asyncapi-tool?ref=abcdef', + repository: { + full_name: 'user/repo1', + html_url: 'https://github.com/user/repo1', + description: 'Description for repo1', + owner: { login: 'asyncapi' } + }, + path: '.asyncapi-tool' + }, + { + name: '.asyncapi-tool', + url: 'https://api.github.com/repositories/789012/contents/.asyncapi-tool?ref=ghijkl', + repository: { + full_name: 'user/repo2', + html_url: 'https://github.com/user/repo2', + description: 'Description for repo2', + owner: { login: 'asyncapi' } + }, + path: '.asyncapi-tool' + } + ] +}; module.exports = { tagsData, From 9d0011049cd05b146b1c8ab613d1498477c392d0 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Wed, 2 Oct 2024 14:31:39 +0530 Subject: [PATCH 14/20] fef --- tests/build-tools.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index a069f1a8d83..d9ecd067b95 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -19,9 +19,9 @@ describe('buildTools', () => { fs.writeFileSync(manualToolsPath, JSON.stringify(manualTools)); }); - // afterAll(() => { - // fs.rmSync(testDir, { recursive: true, force: true }); - // }); + afterAll(() => { + fs.rmSync(testDir, { recursive: true, force: true }); + }); beforeEach(() => { jest.clearAllMocks(); From 7b8a407c77cd50d0fe712cc0bb663a43264fdfde Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Wed, 2 Oct 2024 14:46:04 +0530 Subject: [PATCH 15/20] fefwf --- tests/build-tools.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index d9ecd067b95..3fb79b91471 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -5,6 +5,13 @@ const { tagsData, manualTools, mockConvertedData, initialToolsData, mockExtractD const fs = require('fs'); jest.mock('axios'); +jest.mock('../scripts/tools/categorylist', () => ({ + categoryList: [ + { name: 'Category1', description: 'Description for Category1' }, + { name: 'Category2', description: 'Description for Category2' } + ] +})); + describe('buildTools', () => { const testDir = resolve(__dirname, 'test_config'); From 0c4efb2573c78ea829e5f8d4e95a55913aa1c9d6 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Wed, 2 Oct 2024 14:53:34 +0530 Subject: [PATCH 16/20] fwqwf --- scripts/tools/combine-tools.js | 1 + tests/build-tools.test.js | 8 -------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/scripts/tools/combine-tools.js b/scripts/tools/combine-tools.js index 602262428fa..2e667fca428 100644 --- a/scripts/tools/combine-tools.js +++ b/scripts/tools/combine-tools.js @@ -135,6 +135,7 @@ const combineTools = async (automatedTools, manualTools, toolsPath, tagsPath) => finalToolsList.sort((tool, anotherTool) => tool.title.localeCompare(anotherTool.title)); finalTools[key].toolsList = finalToolsList } + console.log('Final tools object:', finalTools); fs.writeFileSync(toolsPath,JSON.stringify(finalTools)); fs.writeFileSync(tagsPath,JSON.stringify({ languages: languageList, technologies: technologyList }),) } diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index 3fb79b91471..be468bc76d6 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -41,17 +41,9 @@ describe('buildTools', () => { const automatedToolsContent = JSON.parse(fs.readFileSync(automatedToolsPath, 'utf8')); - // Check important properties expect(Object.keys(automatedToolsContent)).toEqual(Object.keys(mockConvertedData)); expect(automatedToolsContent["Category1"].description).toEqual(mockConvertedData["Category1"].description); expect(automatedToolsContent["Category2"].description).toEqual(mockConvertedData["Category2"].description); - - const manualToolsData = JSON.parse(fs.readFileSync(manualToolsPath, 'utf8')); - const tagsFileData = JSON.parse(fs.readFileSync(tagsPath, 'utf8')); - const toolsFileData = JSON.parse(fs.readFileSync(toolsPath, 'utf8')); - - expect(toolsFileData).toEqual(initialToolsData); - expect(tagsFileData).toEqual(tagsData); }); it('should handle getData error', async () => { From 61b3e16750e38c82f2209337aae0a1fd96d54601 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Wed, 2 Oct 2024 15:00:19 +0530 Subject: [PATCH 17/20] fwaf --- tests/build-tools.test.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index be468bc76d6..e2a72b949c5 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -13,6 +13,17 @@ jest.mock('../scripts/tools/categorylist', () => ({ })); +jest.mock('../scripts/tools/tags-color', () => ({ + languagesColor: [ + { name: 'JavaScript', color: 'bg-[#f1e05a]', borderColor: 'border-[#f1e05a]' }, + { name: 'Python', color: 'bg-[#3572A5]', borderColor: 'border-[#3572A5]' } + ], + technologiesColor: [ + { name: 'React', color: 'bg-[#61dafb]', borderColor: 'border-[#61dafb]' }, + { name: 'Node.js', color: 'bg-[#68a063]', borderColor: 'border-[#68a063]' } + ] +})); + describe('buildTools', () => { const testDir = resolve(__dirname, 'test_config'); const toolsPath = resolve(testDir, 'tools.json'); @@ -40,10 +51,16 @@ describe('buildTools', () => { await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); const automatedToolsContent = JSON.parse(fs.readFileSync(automatedToolsPath, 'utf8')); - + const combinedToolsContent = JSON.parse(fs.readFileSync(toolsPath, 'utf8')); + const tagsContent = JSON.parse(fs.readFileSync(tagsPath, 'utf8')); expect(Object.keys(automatedToolsContent)).toEqual(Object.keys(mockConvertedData)); expect(automatedToolsContent["Category1"].description).toEqual(mockConvertedData["Category1"].description); expect(automatedToolsContent["Category2"].description).toEqual(mockConvertedData["Category2"].description); + + expect(combinedToolsContent).toHaveProperty('Category1'); + expect(combinedToolsContent).toHaveProperty('Category2'); + expect(tagsContent).toEqual(tagsData); + }); it('should handle getData error', async () => { From e99f5cf614564b0f2d22fe67ccb1a0fdf2b0a24e Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Wed, 2 Oct 2024 15:04:50 +0530 Subject: [PATCH 18/20] fwfw --- scripts/tools/combine-tools.js | 1 - tests/build-tools.test.js | 7 +++++-- tests/fixtures/buildToolsData.js | 26 -------------------------- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/scripts/tools/combine-tools.js b/scripts/tools/combine-tools.js index 2e667fca428..602262428fa 100644 --- a/scripts/tools/combine-tools.js +++ b/scripts/tools/combine-tools.js @@ -135,7 +135,6 @@ const combineTools = async (automatedTools, manualTools, toolsPath, tagsPath) => finalToolsList.sort((tool, anotherTool) => tool.title.localeCompare(anotherTool.title)); finalTools[key].toolsList = finalToolsList } - console.log('Final tools object:', finalTools); fs.writeFileSync(toolsPath,JSON.stringify(finalTools)); fs.writeFileSync(tagsPath,JSON.stringify({ languages: languageList, technologies: technologyList }),) } diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index e2a72b949c5..b29f1719418 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -1,7 +1,7 @@ const axios = require('axios'); const { resolve } = require('path'); const { buildTools } = require('../scripts/build-tools'); -const { tagsData, manualTools, mockConvertedData, initialToolsData, mockExtractData } = require('../tests/fixtures/buildToolsData'); +const { tagsData, manualTools, mockConvertedData, mockExtractData } = require('../tests/fixtures/buildToolsData'); const fs = require('fs'); jest.mock('axios'); @@ -30,7 +30,6 @@ describe('buildTools', () => { const tagsPath = resolve(testDir, 'all-tags.json'); const automatedToolsPath = resolve(testDir, 'tools-automated.json'); const manualToolsPath = resolve(testDir, 'tools-manual.json'); - console.log(testDir, toolsPath, tagsPath, automatedToolsPath, manualToolsPath); beforeAll(() => { fs.mkdirSync(testDir, { recursive: true }); @@ -53,12 +52,16 @@ describe('buildTools', () => { const automatedToolsContent = JSON.parse(fs.readFileSync(automatedToolsPath, 'utf8')); const combinedToolsContent = JSON.parse(fs.readFileSync(toolsPath, 'utf8')); const tagsContent = JSON.parse(fs.readFileSync(tagsPath, 'utf8')); + expect(Object.keys(automatedToolsContent)).toEqual(Object.keys(mockConvertedData)); expect(automatedToolsContent["Category1"].description).toEqual(mockConvertedData["Category1"].description); expect(automatedToolsContent["Category2"].description).toEqual(mockConvertedData["Category2"].description); expect(combinedToolsContent).toHaveProperty('Category1'); expect(combinedToolsContent).toHaveProperty('Category2'); + expect(combinedToolsContent["Category1"].description).toEqual(mockConvertedData["Category1"].description); + expect(combinedToolsContent["Category2"].description).toEqual(mockConvertedData["Category2"].description); + expect(tagsContent).toEqual(tagsData); }); diff --git a/tests/fixtures/buildToolsData.js b/tests/fixtures/buildToolsData.js index 4c5996f95bf..e4425815323 100644 --- a/tests/fixtures/buildToolsData.js +++ b/tests/fixtures/buildToolsData.js @@ -49,31 +49,6 @@ const mockConvertedData = { } }; -const initialToolsData = { - "Category1": { - description: "Description for Category1", - toolsList: [ - { - title: "Tool 1", - description: "Description for tool 1", - links: { repoUrl: "https://github.com/tool1" }, - filters: { categories: ["Category1"], language: "JavaScript", technology: ["React"] } - } - ] - }, - "Category2": { - description: "Description for Category2", - toolsList: [ - { - title: "Tool 2", - description: "Description for tool 2", - links: { repoUrl: "https://github.com/tool2" }, - filters: { categories: ["Category2"], language: "Python", technology: ["Node.js"] } - } - ] - } -}; - const mockExtractData = { items: [ { @@ -105,6 +80,5 @@ module.exports = { tagsData, manualTools, mockConvertedData, - initialToolsData, mockExtractData, }; From 5cbe440ee450597d814ccbae69b1ed5f5b0dc508 Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Wed, 2 Oct 2024 15:09:22 +0530 Subject: [PATCH 19/20] test updated --- tests/build-tools.test.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index b29f1719418..f898d6f5359 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -10,17 +10,16 @@ jest.mock('../scripts/tools/categorylist', () => ({ { name: 'Category1', description: 'Description for Category1' }, { name: 'Category2', description: 'Description for Category2' } ] -})); - +})); jest.mock('../scripts/tools/tags-color', () => ({ languagesColor: [ - { name: 'JavaScript', color: 'bg-[#f1e05a]', borderColor: 'border-[#f1e05a]' }, - { name: 'Python', color: 'bg-[#3572A5]', borderColor: 'border-[#3572A5]' } + { name: 'JavaScript', color: 'bg-[#f1e05a]', borderColor: 'border-[#f1e05a]' }, + { name: 'Python', color: 'bg-[#3572A5]', borderColor: 'border-[#3572A5]' } ], technologiesColor: [ - { name: 'React', color: 'bg-[#61dafb]', borderColor: 'border-[#61dafb]' }, - { name: 'Node.js', color: 'bg-[#68a063]', borderColor: 'border-[#68a063]' } + { name: 'React', color: 'bg-[#61dafb]', borderColor: 'border-[#61dafb]' }, + { name: 'Node.js', color: 'bg-[#68a063]', borderColor: 'border-[#68a063]' } ] })); @@ -77,32 +76,36 @@ describe('buildTools', () => { }); it('should handle convertTools error', async () => { - axios.get.mockResolvedValue({ data: mockExtractData }); - jest.spyOn(require('../scripts/tools/tools-object'), 'convertTools').mockRejectedValue(new Error('Convert error')); + axios.get.mockResolvedValue({ data: { items: [{ name: '.invalid-tool' }] } }); try { await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); } catch (err) { - expect(err.message).toContain('Convert error'); + expect(err.message).toContain('Invalid .asyncapi-tool file.'); } }); it('should handle combineTools error', async () => { axios.get.mockResolvedValue({ data: mockExtractData }); - jest.spyOn(require('../scripts/tools/tools-object'), 'convertTools').mockResolvedValue(mockConvertedData); - jest.spyOn(require('../scripts/tools/combine-tools'), 'combineTools').mockRejectedValue(new Error('Combine Tools error')); + const invalidManualTools = [ + { + title: "Invalid Tool", + description: "Description for invalid tool", + links: { repoUrl: "https://github.com/invalid/tool" }, + filters: { categories: ["InvalidCategory"], language: "UnknownLanguage", technology: ["UnknownTech"] } + } + ]; + fs.writeFileSync(manualToolsPath, JSON.stringify(invalidManualTools)); try { await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); } catch (err) { - expect(err.message).toContain('Combine Tools error'); + expect(err.message).toContain('Invalid Invalid Tool .asyncapi-tool file.'); } }); it('should handle file write errors', async () => { axios.get.mockResolvedValue({ data: mockExtractData }); - jest.spyOn(require('../scripts/tools/tools-object'), 'convertTools').mockResolvedValue(mockConvertedData); - jest.spyOn(require('../scripts/tools/combine-tools'), 'combineTools').mockResolvedValue(true); const invalidPath = '/invalid_dir/tools.json'; From 46002502e57f316dcba7784a7403f30aa658757a Mon Sep 17 00:00:00 2001 From: Ansh Goyal Date: Thu, 3 Oct 2024 02:22:14 +0000 Subject: [PATCH 20/20] remove redundant tests --- scripts/build-tools.js | 4 ++-- tests/build-tools.test.js | 31 +------------------------------ 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/scripts/build-tools.js b/scripts/build-tools.js index abb9fd09594..84965815dcc 100644 --- a/scripts/build-tools.js +++ b/scripts/build-tools.js @@ -8,12 +8,12 @@ const buildTools = async (automatedToolsPath, manualToolsPath, toolsPath, tagsPa try { let githubExtractData = await getData(); let automatedTools = await convertTools(githubExtractData); - + fs.writeFileSync( automatedToolsPath, JSON.stringify(automatedTools, null, ' ') ); - + await combineTools(automatedTools, require(manualToolsPath), toolsPath, tagsPath); } catch (err) { throw new Error(`An error occurred while building tools: ${err.message}`); diff --git a/tests/build-tools.test.js b/tests/build-tools.test.js index f898d6f5359..2bc4592e8e1 100644 --- a/tests/build-tools.test.js +++ b/tests/build-tools.test.js @@ -10,7 +10,7 @@ jest.mock('../scripts/tools/categorylist', () => ({ { name: 'Category1', description: 'Description for Category1' }, { name: 'Category2', description: 'Description for Category2' } ] -})); +})); jest.mock('../scripts/tools/tags-color', () => ({ languagesColor: [ @@ -75,35 +75,6 @@ describe('buildTools', () => { } }); - it('should handle convertTools error', async () => { - axios.get.mockResolvedValue({ data: { items: [{ name: '.invalid-tool' }] } }); - - try { - await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); - } catch (err) { - expect(err.message).toContain('Invalid .asyncapi-tool file.'); - } - }); - - it('should handle combineTools error', async () => { - axios.get.mockResolvedValue({ data: mockExtractData }); - const invalidManualTools = [ - { - title: "Invalid Tool", - description: "Description for invalid tool", - links: { repoUrl: "https://github.com/invalid/tool" }, - filters: { categories: ["InvalidCategory"], language: "UnknownLanguage", technology: ["UnknownTech"] } - } - ]; - fs.writeFileSync(manualToolsPath, JSON.stringify(invalidManualTools)); - - try { - await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); - } catch (err) { - expect(err.message).toContain('Invalid Invalid Tool .asyncapi-tool file.'); - } - }); - it('should handle file write errors', async () => { axios.get.mockResolvedValue({ data: mockExtractData });