Skip to content

Conversation

@JeelRajodiya
Copy link
Contributor

@JeelRajodiya JeelRajodiya commented Nov 22, 2024

Description

  • The PR migrates the build scripts to Typescript

βœ… Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
πŸ” Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/678b5e3ee3013d00087ed64b
😎 Deploy Preview https://deploy-preview-3423--asyncapi-website.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Related issue(s)
Related to #3187

Summary by CodeRabbit

  • New Features

    • Enhanced internationalization support with refined locale settings for improved multi-language consistency.
    • Upgraded content navigation and aggregation across blogs, documentation, case studies, and tool listings for a smoother user experience.
    • Improved RSS feed generation to ensure timely content updates.
    • Introduced a logging utility for better error and progress tracking across various modules.
    • Added new functions for processing and validating tools data, enhancing the tools management system.
    • Added a new configuration for internationalization, supporting multiple locales and namespaces.
    • New functionality for validating and processing markdown files, improving content quality assurance.
    • Added new error handling tests and validations for tools and video fetching processes.
  • Refactor & Chores

    • Extensive migration to modern TypeScript and module standards, boosting overall stability and maintainability.
    • Streamlined build and configuration processes with updated dependencies for future scalability.
    • Transitioned to ES module syntax for improved compatibility and maintainability.
    • Updated test suites to utilize TypeScript and centralized logging for enhanced error handling and reporting.
    • Adjusted import paths and updated file extensions across various modules to reflect the TypeScript transition.
    • Enhanced error handling and logging throughout various scripts to improve reliability and traceability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 22, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request introduces extensive changes across configuration files, scripts, utilities, and tests. Major updates include ESLint and Next-i18next configuration modifications, a shift from CommonJS to ES module syntax, and migration of many JavaScript files to TypeScript with richer type annotations and error handling. Multiple build scripts (for docs, meetings, newsroom videos, posts, tools, case studies, etc.) have been refactored or replaced. Additionally, new logging via Winston has been integrated, types and declaration files have been added or updated, and tests have been revised to use the new TypeScript modules and logger mocks.

Changes

File(s) Change Summary
.eslintrc Added new override for scripts/**/* (disabling import/no-extraneous-dependencies) and modified override for components/logos/* (disabling max-len).
next-i18next.config.cjs
next-i18next.config.js
Introduced new next-i18next.config.cjs for internationalization and removed the old .js config.
package.json Added "type": "module", updated script commands to use tsx, replaced and updated dependencies (e.g. typescript to ^5.7.2, added winston).
pages/_document.tsx Updated import path for i18next configuration from .config to .config.cjs.
scripts/adopters/index.js
scripts/adopters/index.ts
Removed JS version and added a new asynchronous TS function buildAdoptersList for processing adopter data.
scripts/build-docs.ts Added functions buildNavTree, convertDocPosts, and addDocButtons with enhanced error handling and TypeScript definitions.
scripts/build-meetings.ts Transitioned to ES module syntax with explicit type annotations and improved error handling around Google Calendar API integration.
scripts/build-newsroom-videos.js
scripts/build-newsroom-videos.ts
Removed the JS implementation and introduced a new TS version for fetching and processing YouTube video data, including environment validation.
scripts/build-pages.ts Converted to ES module syntax and added type annotations in functions like ensureDirectoryExists, capitalizeJsxTags, and copyAndRenameFiles.
scripts/build-post-list.js
scripts/build-post-list.ts
Removed the JS file and created a robust TS version with new helper functions (slugifyToC, addItem) for generating post lists.
scripts/build-rss.js
scripts/build-rss.ts
Migrated from JS to TS for generating RSS feeds with detailed error handling, type definitions, and enhanced feed construction logic.
scripts/build-tools.js
scripts/build-tools.ts
Replaced the JS module with a new TS implementation (buildTools) that merges automated and manual tool data using improved type safety and error management.
scripts/casestudies/index.js
scripts/casestudies/index.ts
Removed the JS version and added a new asynchronous TS function buildCaseStudiesList to process case study files robustly.
scripts/compose.ts Transitioned from CommonJS to ES modules with added TypeScript types (ComposePromptType) and refined front matter generation logic.
scripts/dashboard/build-dashboard.ts
scripts/dashboard/issue-queries.ts
Updated dashboard scripts with improved type annotations, new helper functions (e.g. monthsSince, getLabel), and migration to ES modules.
scripts/finance/index.js
scripts/finance/index.ts
Replaced the JS version of buildFinanceInfoList with a new TS implementation using explicit types and robust error handling.
scripts/index.ts Refactored to use ES module syntax with dynamic path resolution and orchestration of multiple build processes.
scripts/utils.js
scripts/utils.ts
scripts/utils/readAndWriteJson.js
scripts/utils/readAndWriteJson.ts
Migrated utility functions to TS; added a new helper pause, and restructured convertToJson and writeJSON for better error reporting.
Files under scripts/tools/ (e.g. categorylist.js/.ts, combine-tools.js/.ts, extract-tools-github.js/.ts, tags-color.js/.ts, tools-object.js/.ts, tools-schema.json) Removed JS modules and introduced comprehensive TS implementations for tool categorization, merging, data extraction from GitHub, and enhanced schema definitions with improved type safety.
tsconfig.json Updated configuration: added "target": "ES2022", reformatted lib and paths, and adjusted include settings.
Multiple declaration files under types/ Added/updated TypeScript declarations for modules such as jgexml/json2xml, markdown-toc, and for various scripts (e.g., build-post-list, build-rss, dashboard, tools) to ensure robust type checking.
Tests (various files under tests/) Updated import paths from .js to .ts, integrated logger mocks replacing console logging, and adjusted tests to work with new TypeScript implementations.
jest.config.js Switched from CommonJS to ES module syntax and updated coverage options to include TypeScript files.
tests/babel.test.config.cjs Added new Babel configuration for transforming TS code prior to testing.

Suggested labels

ready-to-merge, gsoc

Suggested reviewers

  • derberg
  • magicmatatjahu
  • anshgoyalevil
  • devilkiller-ag
  • sambhavgupta0705
  • Mayaleeeee
  • asyncapi-bot-eve

Poem

I'm a little rabbit, hopping through the code,
With TypeScript trails and ES modules in load.
I nibble on errors, logging each hop along the way,
Converting JS to TS, making improvements each day.
With tests in my pouch and configs so neat,
I celebrate these changes with a joyful beat!
Hop, hop, code onβ€”it's a bouncy new day!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❀️ Share
πŸͺ§ Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@netlify
Copy link

netlify bot commented Nov 22, 2024

βœ… Deploy Preview for asyncapi-website ready!

Name Link
πŸ”¨ Latest commit e38d3be
πŸ” Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/67c0b7e10544650008e7530d
😎 Deploy Preview https://deploy-preview-3423--asyncapi-website.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@JeelRajodiya JeelRajodiya changed the title Script migration 2 refactor: migrate build script to typescript Nov 22, 2024
Comment on lines 10 to 17
const caseStudiesList = await Promise.all(
files.map(async (file) => {
const caseStudyFileName = [dirWithCaseStudy, file].join('/');
const caseStudyContent = await readFile(caseStudyFileName, 'utf-8');

return convertToJson(caseStudyContent);
})
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part refactored to avoid using await inside a loop (eslint error)
https://eslint.org/docs/latest/rules/no-await-in-loop

@asyncapi-bot asyncapi-bot requested a review from Aahil13 February 27, 2025 18:03
@akshatnema
Copy link
Member

/rtm

@akshatnema akshatnema merged commit b4a35bf into asyncapi:migrate-scripts Mar 1, 2025
16 of 19 checks passed
akshatnema added a commit that referenced this pull request Mar 5, 2025
* refactor: migrate build script to typescript  (#3423)

* fix eslint error

* rename

* rename

* fix eslint error

* add error type

* add new types

* add types

* refactor and fix eslint errors

* use google apis and add types

* remove console log

* add specific rules for the script folder

* refactor dir variables

* add types and refactor it

* refactor: update eslint rules

* reformat document

* update include paths

* use dynamic import

* reformat eslintrc

* update rules

* change tabs to spaces

* update ts node config

* migrate tools scripts

* refactor __dirname variable

* refactor function in build-rss

* add new package type

* Added error handling for undefined types

* add types

* refactor adopter/index.ts

* use tsx instead of ts-node

* add types for build RSS

* revert name

* fix name

* fix name

* fix name

* Original name

* Rename next-i18next.config.js to next-i18next.config.cjs

* migrate build-post-list.ts

* use old package-lock file

* No code changes made

* migrate check-markdown.ts

* feat: add TypeScript types for tools and categories

* update type

* feat: enhance type safety in combine-tools script with TypeScript types

* chore: disable eslint rule for no-await-in-loop in combine-tools script

* feat: improve type safety and refactor dashboard script functions

* feat: add TypeScript types for dashboard script and enhance type safety

* No code changes detected.

* update package json

* refactor: remove console log from buildPostList function

* fix: update workflow to conditionally install dependencies based on package.json existence

* chore: remove unused PowerShell script and TypeScript type definitions

* refactor: add type annotations to capitalizeJsxTags function parameters

* refactor: migrate build-docs

* refactor: remove unused URL validation function from check-markdown.ts

* chore: update Jest configuration and dependencies for TypeScript support

* chore: enable ES module support in Jest configuration

* chore: update Jest configuration for TypeScript file handling and coverage

* chore: update Jest configuration to set test environment to Node

* chore: enable ES module support in ts-jest transformer

* refactor: update case studies import to default export and improve type imports

* refactor: update Jest configuration for improved TypeScript support

* refactor: change imports to default exports for consistency

* refactor: update test imports to remove file extensions for consistency

* refactor: simplify Jest transform configuration for TypeScript files

* refactor: update dynamic import for manual tools and mock axios in tests

* refactor: update path resolution to use fileURLToPath for better compatibility

* refactor: update path resolution to use fileURLToPath for improved compatibility

* refactor: improve optional chaining usage and enhance tool validation logging

* refactor: enable ESM support in ts-jest transform configuration

* refactor: update ts-jest configuration to use ESNext module in tsconfig

* refactor: add support for ESM by updating Jest configuration and TypeScript target

* refactor: enhance Jest configuration for ESM support and improve module resolution

* refactor: update Jest configuration to use ES2022 module and target

* refactor: simplify JSON import in build-rss and remove debug log in combine-tools

* Revert "refactor: improve optional chaining usage and enhance tool validation logging"

This reverts commit d6b0e2a.

* refactor: update type definitions for discussions and improve null handling

* refactor: improve optional chaining for language filter in getFinalTool function

* refactor: clean up code formatting and improve consistency across utility functions

* refactor: change getData to an exported function and update TypeScript target version

* refactor: remove unused slugify function declaration from markdown-toc module

* refactor: update guid type in RSSItemType to include isPermaLink property

* refactor: replace manual path joining with path.join for better compatibility

* refactor: change parameter type of convertToJson function to unknown for better type safety

* refactor: add return type Promise<void> to buildFinanceInfoList function for better clarity

* refactor: use optional chaining for safer access to video properties in buildNewsroomVideos function

* refactor: simplify interfaces by introducing BasicIssueOrPR for shared properties

* refactor: enhance MarkdownToken interface with optional properties for better flexibility

* refactor: update tool handling by replacing dynamic import with JSON parsing and enhancing type definitions for better clarity and safety

* test: update mock path for readAndWriteJson to include file extension

* refactor: simplify Jest configuration by removing unnecessary options and streamlining transform settings

* refactor: update imports to use named exports for consistency and clarity

* refactor: simplify Jest configuration by utilizing ts-jest preset and removing unnecessary transform settings

* refactor: enhance type safety by casting imported JSON as 'any' in getAllPosts function

* refactor: enhance Jest configuration by integrating ts-jest preset with ESM support for JSON transformation

* refactor: enhance Jest configuration by enabling JSON module resolution in ts-jest preset

* refactor: simplify Jest configuration by removing JSON transform settings and adjusting transformIgnorePatterns

* refactor: update Jest configuration to specify tsconfig for ts-jest preset

* refactor: clean up test files by removing test directory after execution and updating fs module import

* refactor: update import statement for pathExists from fs-extra to improve compatibility

* refactor: remove assert statements and export utility functions for better error handling and reusability

* feat: add TypeScript declaration for JSON module to improve type safety

* feat: add Babel configuration and TypeScript presets for improved compatibility

* refactor: remove assert statements and improve error handling in build scripts

* feat: replace Google APIs client with node-fetch for YouTube data retrieval and improve error handling

* feat: update Jest and Babel configuration for TypeScript support and improve test script transformation

* fix: correct filename for automated tools configuration in build script

* chore: remove ts-jest from package.json and package-lock.json

* refactor: replace assert statements with error handling in scripts

* ci: replace npm install with npm ci for dependency installation in workflow

* feat: add JSDoc comments for improved documentation across various scripts

* chore: remove unnecessary roots configuration from Jest config

* chore: clean up tsconfig.json by removing unused ts-node configuration

* test: remove redundant axios.get mock initialization in tools-object tests

* test: fix indentation in cleanup comment for build-pages tests

* fix: correct typo in comment for additional check in build-docs script

* fix: update type annotation for validateFunction parameter in checkMarkdownFiles

* fix: add error handling for missing CALENDAR_SERVICE_ACCOUNT environment variable

* fix: add error handling for missing YOUTUBE_TOKEN and validate video data structure in buildNewsroomVideos function

* fix: remove redundant error handling for missing CALENDAR_SERVICE_ACCOUNT environment variable in buildMeetings function

* fix: add file existence checks for Expenses.yml and ExpensesLink.yml in buildFinanceInfoList function

* fix: await rssFeed call and add error handling in start function

* fix: add error handling for missing GITHUB_TOKEN environment variable in getData function

* fix: enhance error handling for GitHub API responses in getData function

* refactor: remove file existence checks and simplify start function error handling

* fix: remove GITHUB_TOKEN check from getData function

* fix: add validation for missing frontmatter in validateBlogs function

* feat: implement pagination for GitHub API data retrieval in getData function

* fix: format mockData structure in getData tests for consistency

* refactor: move pause function to utils and remove redundant definition from build-dashboard

* feat: add processManualTool function to validate and process manual tools in combine-tools script

* refactor: remove max-depth eslint rule from combine-tools script

* refactor: remove duplicate Scala color configuration from tags-color script

* feat(logging): integrate Winston logger for improved error handling and logging

* feat(logging): replace console log with Winston logger for GitHub rate limit warnings

* test(logging): update tests to use Winston logger for warnings and errors

* fix: use optional chaining for comments pageInfo in processHotDiscussions function

* refactor: improve type definitions for tools in combine-tools.ts

* refactor(jest): remove 'node' from moduleFileExtensions in jest.config.js

* refactor(logging): replace console.log with logger in scripts

* fix(docs): simplify error handling in buildNavTree function

* fix(errors): simplify error handling in buildMeetings and convertTools functions

* fix(errors): simplify error handling in buildFinanceInfoList function

* fix(validation): return errors when frontmatter is missing in validateBlogs function

* test(validation): update frontmatter validation test for consistency

* test(meetings): add error handling tests for invalid data structure and missing start.dateTime

* fix(videos): improve error handling for missing video properties and add test for YOUTUBE_TOKEN

* test(videos): remove unnecessary whitespace in buildNewsroomVideos test

* test(github): add pagination test for getData function and mock logger

* test(tools): add test for createToolObject with single parameter

* fix(tools): add istanbul ignore comments to enhance test coverage

* fix(tools): simplify language and technology filter checks in getFinalTool function

* feat(tools): export getFinalTool function and enhance test for handling tools with missing data

* test(tools): remove unnecessary blank line in combineTools test suite

* fixed lint errors

* test(markdown): replace console.log with logger.warn in checkMarkdown tests

* test(markdown): refactor checkMarkdown tests for improved readability and consistency

* test: improve test readability and consistency by refactoring whitespace and formatting

* fixed variable naming issue

* fix: update import paths to include .ts extension for build-docs and build-pages tests

* fix: update import paths in utils tests to include .ts extension

* test(markdown): improve test clarity by removing commented-out code

* fix: add istanbul ignore comments to exclude specific lines from coverage

* fix: add istanbul ignore comment to exclude directory check from coverage

* fix: add istanbul ignore comments to improve test coverage exclusions

* test(dashboard): remove commented-out expectation for error logging

* fix: add istanbul ignore comment to exclude title validation from coverage

* refactor: migrate check-edit-links script to TypeScript and update related tests

* fix: add istanbul ignore comments for code coverage in check-edit-links script

* chore: update workflow to trigger on push instead of pull request

* Revert "chore: update workflow to trigger on push instead of pull request"

This reverts commit cc194a6.

* fix(docs): handle undefined document object in convertDocPosts function

* fix: disable eslint rule for no-await-in-loop in combine-tools.ts

* fix: require GITHUB_TOKEN environment variable in getData function

* fix: update getData function to return specific ToolsData type

* test: change link checker workflow trigger to run on push

* fix: remove GITHUB_TOKEN requirement in getData function

* chore: update link checker workflow to run weekly and allow manual triggers

* fix: update i18next config import to use .cjs extension

* Update scripts/adopters/index.ts

Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com>

* fix: require GITHUB_TOKEN environment variable in extract-tools-github script

* fix: validate YOUTUBE_TOKEN and GITHUB_TOKEN environment variables in scripts

* refactor: remove redundant YOUTUBE_TOKEN error test in build-newsroom-videos

* fix: improve type safety in build-rss script by updating post types

* refactor: simplify category extraction logic in getUniqueCategories function

* fix: handle errors while walking directories in build-post-list script

* fix: add error handling and logging in build-tools script

* fix: improve error handling in build-tools script

* refactor: remove unnecessary comment from ensureDirectoryExists function

* Add ts types in return type of functions

* Moved ts to a stable version

---------

Co-authored-by: asyncapi-bot <bot+chan@asyncapi.io>
Co-authored-by: akshatnema <akshatnema.school@gmail.com>
Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com>

* refactor: remove unused monthsSince test in dashboard scripts (#3763)


"Co-authored-by: JeelRajodiya <jeelrajodiyajeel@gmail.com>"

---------

Co-authored-by: Zeel Rajodiya <jeelrajodiyajeel@gmail.com>
Co-authored-by: asyncapi-bot <bot+chan@asyncapi.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants