-
-
Notifications
You must be signed in to change notification settings - Fork 992
refactor: created npm folder and modularized scripts #4192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
akshatnema
merged 83 commits into
asyncapi:add-integration-tests
from
sagarkori143:modules
Aug 4, 2025
Merged
Changes from 78 commits
Commits
Show all changes
83 commits
Select commit
Hold shift + click to select a range
5e57996
created npm folder and modularized scripts
sagarkori143 6ed3594
resolved prod fail issues
sagarkori143 5f27ad2
resolved prod fail issues
sagarkori143 2f4f22f
resolved prod fail issues
sagarkori143 2d499cc
moved the logger to utils
sagarkori143 388dfda
moved the logger to utils
sagarkori143 b382cf6
solving logger imports after refactoring
sagarkori143 075cead
refactored the index.ts file for parallel execution of the scripts
sagarkori143 728ad2b
Merge branch 'master' into modules
asyncapi-bot 9ab9cc3
added more modualarized scripts and runners
sagarkori143 91e952f
Merge branch 'modules' of github.com:sagarkori143/website into modules
sagarkori143 1402f9b
removed extra changes
sagarkori143 b40ab1e
removed extra changes
sagarkori143 5a83f3f
improved error handling
sagarkori143 e10c132
made sure to float the errors to the top level and all files are now …
sagarkori143 dc99fc0
all the scripts are modularized now and are perfectly working
sagarkori143 9d0fc09
minor changes
sagarkori143 241396c
added setup for integration testing and added a few tests for the bui…
sagarkori143 7f34ffa
Merge branch 'master' into modules
sagarkori143 b4c0184
resolving coderabbit reviews on integration tests file
sagarkori143 48c9b20
Merge branch 'master' into modules
sagarkori143 cf0fddd
enhanced error handling of build newsroom videos script to test with …
sagarkori143 e1b44fc
Merge branch 'master' into modules
sagarkori143 e239484
removed the scripts copied in the npm directory and shifted the Int t…
sagarkori143 db991db
updated conflicting path
sagarkori143 0a79ab8
trying to maintain pages as it is and check if build makes up
sagarkori143 4db1a6f
reconfigured the build pages page
sagarkori143 77baacd
reconfigured the build pages page
sagarkori143 6c2c115
reconfigured the build pages page
sagarkori143 6d9872f
started building pages with runners
sagarkori143 3789564
changes suggested by coderabbitAi
sagarkori143 0145bda
reverted the pages changes
sagarkori143 cff3857
reverting the pages script changes to check if everything goes right
sagarkori143 7bfd418
updated build post list according to coderabbit suggestions
sagarkori143 f025abc
retrying the build pages script runners from cli
sagarkori143 d06e25a
did some changes to case study card
sagarkori143 47eeb0b
reverted the case studies changes
sagarkori143 a8335dc
reverted the case studies changes
sagarkori143 ce9fc7c
posts reverted
sagarkori143 96cec2a
separated the unit and integration tests running
sagarkori143 c48f1fd
added more context to the error in blog compose
sagarkori143 f7d9a43
Merge branch 'master' into modules
asyncapi-bot f1192e5
tests fixed
sagarkori143 b206429
Merge branch 'modules' of github.com:sagarkori143/website into modules
sagarkori143 98486af
reverted: tests fixed
sagarkori143 85add6f
minor changes
sagarkori143 800f03d
Merge branch 'master' into modules
sagarkori143 f1b3dc6
made a temp change
sagarkori143 8d2bf22
reverted: made a temp change
sagarkori143 60cf2f9
Merge branch 'master' into modules
sagarkori143 2b13160
tried enhancing the error handling and logging
sagarkori143 e8c2279
fixed the failing tests
sagarkori143 79da91f
reverted integration test change
sagarkori143 8767b93
Merge branch 'master' into modules
asyncapi-bot 0b20bf4
solving the failing tests and changed the integration tests logic to …
sagarkori143 cb4a589
Merge branch 'modules' of github.com:sagarkori143/website into modules
sagarkori143 ce2a5b7
fixed linting errors
sagarkori143 27cf32b
improved code coverage
sagarkori143 592dd9a
Merge branch 'master' into modules
sagarkori143 f836a26
Merge branch 'master' into modules
sagarkori143 8ee27a7
shifted the integration tests out of main tests into a temp folder
sagarkori143 9e68f76
removed index.ts file and removed the linting errors of build dashboa…
sagarkori143 833008f
Merge branch 'master' into modules
sagarkori143 8b501e2
did npm binding of dashboard and case studies runner and improved err…
sagarkori143 1669b3c
reverted the build-pages script in the package.json
sagarkori143 82442c4
building pages with the runners
sagarkori143 a1e8b82
binding of build pages and error handling done
sagarkori143 a65c553
done binding build post list
sagarkori143 d8f51e0
binding of adopters list module
sagarkori143 75599a7
binding done of finance info list builders
sagarkori143 7109472
binding done of meetings.json
sagarkori143 8363ce3
done binding newsroom
sagarkori143 d0ad117
binding tools and error handling improved
sagarkori143 5fea48b
major changes: Refactored all runners, bind them to cli and improved …
sagarkori143 0176ece
rethrew error after logging for surfacing the errror
sagarkori143 1f39b40
removed test file
sagarkori143 c5c0b61
added error classes
akshatnema b043ffd
refactor scripts files
akshatnema f688215
Merge branch 'master' into modules
akshatnema dd9d6e6
empty commit to trigger codecov
akshatnema 11502cc
empty commit to trigger codecov
akshatnema 748c003
added tests to cover 100% test coverage
akshatnema 34637bd
added tests to cover 100% test coverage
akshatnema File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| node_modules/ | ||
| .next/ | ||
| out/ | ||
| public/ | ||
| *.config.js | ||
| *.config.mjs | ||
| .storybook/ | ||
| coverage/ | ||
| netlify/ | ||
| cypress/ | ||
| dist/ | ||
| build/ | ||
| next-env.d.ts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { buildAdoptersList } from '@/scripts/adopters'; | ||
| import { logger } from '@/scripts/helpers/logger'; | ||
| import { CustomError } from '@/types/errors/CustomError'; | ||
|
|
||
| /** | ||
| * Runs the build adopters list process. | ||
| * | ||
| * This function invokes the buildAdoptersList script and handles errors, | ||
| * logging them with context and letting the top-level .catch handle process exit. | ||
| * @throws {CustomError} When the build process fails | ||
| */ | ||
| async function runBuildAdoptersList(): Promise<void> { | ||
| try { | ||
| await buildAdoptersList(); | ||
| } catch (error) { | ||
| const customError = CustomError.fromError(error, { | ||
| category: 'script', | ||
| operation: 'runBuildAdoptersList', | ||
| detail: 'Build adopters list runner failed' | ||
| }); | ||
|
|
||
| logger.error('Build adopters list runner failed', customError); | ||
|
|
||
| throw customError; | ||
| } | ||
| } | ||
|
|
||
| // Self-executing async function to handle top-level await | ||
| (async () => { | ||
| try { | ||
| await runBuildAdoptersList(); | ||
| } catch { | ||
| process.exit(1); | ||
| } | ||
| })(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { dirname, resolve } from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
|
|
||
| import { start as buildDashboard } from '@/scripts/dashboard/build-dashboard'; | ||
| import { logger } from '@/scripts/helpers/logger'; | ||
| import { CustomError } from '@/types/errors/CustomError'; | ||
|
|
||
| const currentFilePath = fileURLToPath(import.meta.url); | ||
| const currentDirPath = dirname(currentFilePath); | ||
|
|
||
| interface BuildDashboardOptions { | ||
| outputPath?: string; | ||
| } | ||
|
|
||
| /** | ||
| * Runs the dashboard generation process with configurable options. | ||
| * | ||
| * This function resolves the path to the dashboard.json output file, | ||
| * then invokes the buildDashboard script. It handles errors, logging them with context | ||
| * and letting the top-level .catch handle process exit. | ||
| * | ||
| * @param options - Optional configuration for output path | ||
| * @throws {CustomError} If the build process fails or an error occurs in the runner | ||
| */ | ||
| async function runBuildDashboard(options: BuildDashboardOptions = {}): Promise<void> { | ||
| try { | ||
| const outputPath = options.outputPath || resolve(currentDirPath, '../../dashboard.json'); | ||
|
|
||
| await buildDashboard(outputPath); | ||
| } catch (error) { | ||
| // Create or enhance the error with full context | ||
| const customError = | ||
| error instanceof CustomError | ||
| ? error.updateContext({ | ||
| operation: 'runBuildDashboard', | ||
| detail: `Runner failed with output path: ${options.outputPath}` | ||
| }) | ||
| : CustomError.fromError(error, { | ||
| category: 'script', | ||
| operation: 'runBuildDashboard', | ||
| detail: `Build dashboard runner failed with output path: ${options.outputPath}` | ||
| }); | ||
|
|
||
| // Log error with full context | ||
| logger.error('Build dashboard runner failed', customError); | ||
|
|
||
| throw customError; | ||
| } | ||
| } | ||
|
|
||
| // Run only in non-test environments | ||
| if (process.env.NODE_ENV === 'test') { | ||
| logger.info('Skipping dashboard build in test environment'); | ||
| } else { | ||
| // Self-executing async function to handle top-level await | ||
| (async () => { | ||
| try { | ||
| await runBuildDashboard(); | ||
| } catch (error) { | ||
| // Ensure we exit with error code | ||
| process.exit(1); | ||
| } | ||
| })(); | ||
| } | ||
|
|
||
| // Export for testing purposes | ||
| export { runBuildDashboard }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| import fs from 'fs'; | ||
| import { resolve } from 'path'; | ||
|
|
||
| import { buildFinanceInfoList } from '@/scripts/finance'; | ||
| import { logger } from '@/scripts/helpers/logger'; | ||
| import { CustomError } from '@/types/errors/CustomError'; | ||
|
|
||
| interface BuildFinanceInfoOptions { | ||
| currentDir?: string; | ||
| configDir?: string; | ||
| financeDir?: string; | ||
| jsonDataDir?: string; | ||
| year?: string; | ||
| } | ||
|
|
||
| const DEFAULT_OPTIONS = { | ||
| currentDir: '.', | ||
| configDir: 'config', | ||
| financeDir: 'finance', | ||
| jsonDataDir: 'json-data' | ||
| }; | ||
|
|
||
| /** | ||
| * Runs the build finance info list process with configurable options. | ||
| * | ||
| * This function locates the latest year in the finance directory, | ||
| * then invokes the buildFinanceInfoList script for that year. | ||
| * It handles errors, logging them with context and letting the top-level .catch handle process exit. | ||
| * | ||
| * @param options - Optional configuration for directories and year | ||
| * @throws {CustomError} If the build process fails or an error occurs in the runner | ||
| */ | ||
| async function runBuildFinanceInfoList(options: BuildFinanceInfoOptions = {}): Promise<void> { | ||
| const config = { ...DEFAULT_OPTIONS, ...options }; | ||
|
|
||
| const financeDir = resolve(config.currentDir, config.configDir, config.financeDir); | ||
|
|
||
| try { | ||
| // If year is not provided, find the latest year | ||
| let targetYear = config.year; | ||
|
|
||
| if (!targetYear) { | ||
| const yearsList = fs | ||
| .readdirSync(financeDir) | ||
| // Filter out any files that are not numbers | ||
| .filter((file) => !Number.isNaN(parseFloat(file))) | ||
| // Sort the years in descending order | ||
| .sort((a, b) => parseFloat(b) - parseFloat(a)); | ||
|
|
||
| if (yearsList.length === 0) { | ||
| throw new CustomError('No finance data found in the finance directory', { | ||
| category: 'script', | ||
| operation: 'findLatestYear', | ||
| detail: `Finance directory: ${financeDir}, Available years: ${yearsList.join(', ')}` | ||
| }); | ||
| } | ||
|
|
||
| const [latestYear] = yearsList; | ||
|
|
||
| targetYear = latestYear; | ||
| } | ||
|
|
||
| await buildFinanceInfoList({ | ||
| currentDir: config.currentDir, | ||
| configDir: config.configDir, | ||
| financeDir: config.financeDir, | ||
| year: targetYear, | ||
| jsonDataDir: config.jsonDataDir | ||
| }); | ||
| } catch (error) { | ||
| const customError = CustomError.fromError(error, { | ||
| category: 'script', | ||
| operation: 'runBuildFinanceInfoList', | ||
| detail: `Build finance info failed for year: ${config.year}, financeDir: ${financeDir}` | ||
| }); | ||
|
|
||
| logger.error('Build finance info list runner failed', customError); | ||
|
|
||
| throw customError; | ||
| } | ||
| } | ||
|
|
||
| // Run only in non-test environments | ||
| if (process.env.NODE_ENV === 'test') { | ||
| logger.info('Skipping finance info list build in test environment'); | ||
| } else { | ||
| // Self-executing async function to handle top-level await | ||
| (async () => { | ||
| try { | ||
| await runBuildFinanceInfoList(); | ||
| } catch (error) { | ||
| // Ensure we exit with error code | ||
| process.exit(1); | ||
| } | ||
| })(); | ||
| } | ||
|
|
||
| // Export for testing purposes | ||
| export { runBuildFinanceInfoList }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { dirname, resolve } from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
|
|
||
| import { buildMeetings } from '@/scripts/build-meetings'; | ||
| import { logger } from '@/scripts/helpers/logger'; | ||
| import { CustomError } from '@/types/errors/CustomError'; | ||
|
|
||
| const currentFilePath = fileURLToPath(import.meta.url); | ||
| const currentDirPath = dirname(currentFilePath); | ||
|
|
||
| interface BuildMeetingsOptions { | ||
| outputPath?: string; | ||
| } | ||
|
|
||
| /** | ||
| * Runs the build meetings process with configurable options. | ||
| * | ||
| * This function resolves the path to the meetings.json configuration file, | ||
| * then invokes the buildMeetings script. It handles errors, logging them with context | ||
| * and letting the top-level .catch handle process exit. | ||
| * | ||
| * @param options - Optional configuration for output path | ||
| * @throws {CustomError} If the build process fails or an error occurs in the runner | ||
| */ | ||
| async function runBuildMeetings(options: BuildMeetingsOptions = {}): Promise<void> { | ||
| try { | ||
| const outputPath = options.outputPath || resolve(currentDirPath, '../../config', 'meetings.json'); | ||
|
|
||
| await buildMeetings(outputPath); | ||
| } catch (error) { | ||
| const customError = CustomError.fromError(error, { | ||
| category: 'script', | ||
| operation: 'runBuildMeetings', | ||
| detail: `Build meetings failed with output path: ${options.outputPath}` | ||
| }); | ||
|
|
||
| logger.error('Build meetings runner failed', customError); | ||
|
|
||
| throw customError; | ||
| } | ||
| } | ||
|
|
||
| // Run only in non-test environments | ||
| if (process.env.NODE_ENV === 'test') { | ||
| logger.info('Skipping meetings build in test environment'); | ||
| } else { | ||
| // Self-executing async function to handle top-level await | ||
| (async () => { | ||
| try { | ||
| await runBuildMeetings(); | ||
| } catch (error) { | ||
| // Ensure we exit with error code | ||
| process.exit(1); | ||
| } | ||
| })(); | ||
| } | ||
|
|
||
| // Export for testing purposes | ||
| export { runBuildMeetings }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { dirname, resolve } from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
|
|
||
| import { buildNewsroomVideos } from '@/scripts/build-newsroom-videos'; | ||
| import { logger } from '@/scripts/helpers/logger'; | ||
| import { CustomError } from '@/types/errors/CustomError'; | ||
|
|
||
| const currentFilePath = fileURLToPath(import.meta.url); | ||
| const currentDirPath = dirname(currentFilePath); | ||
|
|
||
| interface BuildNewsroomVideosOptions { | ||
| outputPath?: string; | ||
| } | ||
|
|
||
| /** | ||
| * Runs the build newsroom videos process with configurable options. | ||
| * | ||
| * This function resolves the path to the newsroom_videos.json configuration file, | ||
| * then invokes the buildNewsroomVideos script. It handles errors, logging them with context | ||
| * and letting the top-level .catch handle process exit. | ||
| * | ||
| * @param options - Optional configuration for output path | ||
| * @throws {CustomError} If the build process fails or an error occurs in the runner | ||
| */ | ||
| async function runBuildNewsroomVideos(options: BuildNewsroomVideosOptions = {}): Promise<void> { | ||
| try { | ||
| const outputPath = options.outputPath || resolve(currentDirPath, '../../config', 'newsroom_videos.json'); | ||
|
|
||
| await buildNewsroomVideos(outputPath); | ||
| } catch (error) { | ||
| const customError = CustomError.fromError(error, { | ||
| category: 'script', | ||
| operation: 'runBuildNewsroomVideos', | ||
| detail: `Build newsroom videos failed with output path: ${options.outputPath}` | ||
| }); | ||
|
|
||
| logger.error('Build newsroom videos runner failed', customError); | ||
|
|
||
| throw customError; | ||
| } | ||
| } | ||
|
|
||
| // Run only in non-test environments | ||
| if (process.env.NODE_ENV === 'test') { | ||
| logger.info('Skipping newsroom videos build in test environment'); | ||
| } else { | ||
| // Self-executing async function to handle top-level await | ||
| (async () => { | ||
| try { | ||
| await runBuildNewsroomVideos(); | ||
| } catch (error) { | ||
| // Ensure we exit with error code | ||
| process.exit(1); | ||
| } | ||
| })(); | ||
| } | ||
|
|
||
| // Export for testing purposes | ||
| export { runBuildNewsroomVideos }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file contains improper eslint formatting with tab width 4. Fix eslint errors in the file.