-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
test #4200
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
test #4200
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { runBuildPostList } from './runners/build-post-list-runner'; | ||
| import { runBuildDashboard } from './runners/build-dashboard-runner'; | ||
| import { runBuildTools } from './runners/build-tools-runner'; | ||
| import { runCaseStudies } from './runners/case-studies-runner'; | ||
| import { runBuildNewsroomVideos } from './runners/build-newsroom-videos-runner'; | ||
| import { logger } from '../scripts/helpers/logger'; | ||
| import { runBuildMeetings } from './runners/build-meetings-runner'; | ||
| import { runBuildFinanceInfoList } from './runners/build-finance-info-list-runner'; | ||
| import { runBuildAdoptersList } from './runners/build-adopters-list-runner'; | ||
| import { runBuildPages } from './runners/build-pages-runner'; | ||
| import { runBuildRss } from './runners/build-rss-runner'; | ||
|
|
||
| async function main() { | ||
| let errorFaced: boolean = false; | ||
|
|
||
| const buildTasks = [ | ||
| { name: 'posts', task: runBuildPostList }, | ||
| { name: 'dashboard', task: runBuildDashboard }, | ||
| { name: 'tools', task: runBuildTools }, | ||
| { name: 'caseStudies', task: runCaseStudies }, | ||
| { name: 'newsroomVideos', task: runBuildNewsroomVideos }, | ||
| { name: 'meetings', task: runBuildMeetings }, | ||
| { name: 'finance', task: runBuildFinanceInfoList }, | ||
| { name: 'adopters', task: runBuildAdoptersList }, | ||
| { name: 'pages', task: runBuildPages }, | ||
| { name: 'rss', task: runBuildRss } | ||
| ]; | ||
|
|
||
| try { | ||
| const results = await Promise.allSettled( | ||
| buildTasks.map(({ task }) => task()) | ||
| ); | ||
|
|
||
| results.forEach((result, index) => { | ||
| if (result.status === 'rejected') { | ||
| errorFaced = true; | ||
| const error = result.reason; | ||
|
|
||
| if (error instanceof Error) { | ||
| const errorDetails = { | ||
| message: error.message, | ||
| cause: error.cause, | ||
| stack: error.stack | ||
| }; | ||
| logger.error(`Error building ${buildTasks[index].name}:`, errorDetails); | ||
| } else { | ||
| logger.error(`Error building ${buildTasks[index].name}:`, error); | ||
| } | ||
| } else { | ||
| logger.info(`Successfully executed ${buildTasks[index].name}`); | ||
| } | ||
| }); | ||
|
|
||
| if (errorFaced) { | ||
| logger.info('Some scripts faced error while running, please check the console for more details'); | ||
| process.exitCode = 1; // surface the failure to CI so that it can be tracked | ||
| } else { | ||
| logger.info('Successfully executed all build scripts'); | ||
| } | ||
| } catch (error) { | ||
| logger.error('Error executing build scripts:', error); | ||
| throw new Error('Error executing build scripts', { cause: error }); | ||
| } | ||
| } | ||
|
|
||
| main(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { buildAdoptersList } from '@/scripts/adopters'; | ||
|
|
||
| export async function runBuildAdoptersList() { | ||
| try{ | ||
| await buildAdoptersList(); | ||
| }catch(error){ | ||
| throw error; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,16 @@ | ||||||||||||||||||||||
| import { start } from "@/scripts/dashboard/build-dashboard"; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import { dirname, resolve } from 'path'; | ||||||||||||||||||||||
| import { fileURLToPath } from 'url'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const currentFilePath = fileURLToPath(import.meta.url); | ||||||||||||||||||||||
| const currentDirPath = dirname(currentFilePath); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export async function runBuildDashboard() { | ||||||||||||||||||||||
| try { | ||||||||||||||||||||||
| await start(resolve(currentDirPath, '..', '..', 'dashboard.json')); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| catch (error) { | ||||||||||||||||||||||
| throw error; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+10
to
+16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Remove the useless try-catch block. The try-catch block only rethrows the original error without adding any value. This makes the code unnecessarily verbose and can be confusing. Apply this diff to simplify the function: export async function runBuildDashboard() {
- try {
- await start(resolve(currentDirPath, '..', '..', 'dashboard.json'));
- }
- catch (error) {
- throw error;
- }
+ await start(resolve(currentDirPath, '..', '..', 'dashboard.json'));
}📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (1.9.4)[error] 14-14: The catch clause that only rethrows the original error is useless. An unnecessary catch clause can be confusing. (lint/complexity/noUselessCatch) 🤖 Prompt for AI Agents |
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { resolve } from "path"; | ||
| import fs from "fs"; | ||
|
|
||
| import { buildFinanceInfoList } from "@/scripts/finance/index"; | ||
|
|
||
|
|
||
| export async function runBuildFinanceInfoList() { | ||
| const financeDir = resolve('.', 'config', 'finance'); | ||
|
|
||
| // loop through all the files finance in directory and find the latest year to build the finance info list | ||
| const yearsList = fs | ||
| .readdirSync(financeDir) | ||
| // filter out any files that are not numbers | ||
| .filter((file) => { | ||
| return !Number.isNaN(parseFloat(file)); | ||
| }) | ||
| // sort the years in descending order | ||
| .sort((a, b) => { | ||
| return parseFloat(b) - parseFloat(a); | ||
| }); | ||
|
|
||
| if (yearsList.length === 0) { | ||
| throw new Error('No finance data found in the finance directory.'); | ||
| } | ||
| const latestYear = yearsList[0]; | ||
| try { | ||
| await buildFinanceInfoList({ | ||
| currentDir: '.', | ||
| configDir: 'config', | ||
| financeDir: 'finance', | ||
| year: latestYear, | ||
| jsonDataDir: 'json-data' | ||
| }); | ||
| } catch (error) { | ||
| throw new Error('Error building finance info list', { cause: error }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { dirname, resolve } from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
| import { buildMeetings } from '@/scripts/build-meetings'; | ||
|
|
||
| const currentFilePath = fileURLToPath(import.meta.url); | ||
| const currentDirPath = dirname(currentFilePath); | ||
|
|
||
| export async function runBuildMeetings(){ | ||
| try{ | ||
| await buildMeetings(resolve(currentDirPath, '../../config', 'meetings.json')); | ||
| }catch (error) { | ||
| if (error instanceof Error) { | ||
| throw new Error(`Build meetings runner failed: ${error.message}`, { cause: error }); | ||
| } else { | ||
| throw new Error(`Build meetings runner failed: ${String(error)}`, { cause: error }); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { buildNewsroomVideos } from "@/scripts/build-newsroom-videos"; | ||
| import { dirname, resolve } from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
|
|
||
| const currentFilePath = fileURLToPath(import.meta.url); | ||
| const currentDirPath = dirname(currentFilePath); | ||
|
|
||
| export async function runBuildNewsroomVideos() { | ||
| try { | ||
| await buildNewsroomVideos(resolve(currentDirPath, '../../config', 'newsroom_videos.json')); | ||
| } | ||
| catch (error) { | ||
| if (error instanceof Error) { | ||
| throw new Error(`Newsroom videos runner failed: ${error.message}`, { cause: error }); | ||
| } else { | ||
| throw new Error(`Newsroom videos runner failed: ${String(error)}`, { cause: error }); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,14 @@ | ||||||||||||||||||||||||||
| import { ensureDirectoryExists, copyAndRenameFiles } from "@/scripts/build-pages"; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const SRC_DIR = 'markdown'; | ||||||||||||||||||||||||||
| const TARGET_DIR = 'pages'; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| export function runBuildPages() { | ||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||
| ensureDirectoryExists(TARGET_DIR); | ||||||||||||||||||||||||||
| copyAndRenameFiles(SRC_DIR, TARGET_DIR); | ||||||||||||||||||||||||||
| } catch (err) { | ||||||||||||||||||||||||||
| throw err; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+7
to
+14
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Remove the unnecessary try-catch block. The try-catch block serves no purpose since it only rethrows the original error without adding any value. -export function runBuildPages() {
- try {
- ensureDirectoryExists(TARGET_DIR);
- copyAndRenameFiles(SRC_DIR, TARGET_DIR);
- } catch (err) {
- throw err;
- }
-}
+export function runBuildPages() {
+ ensureDirectoryExists(TARGET_DIR);
+ copyAndRenameFiles(SRC_DIR, TARGET_DIR);
+}📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (1.9.4)[error] 12-12: The catch clause that only rethrows the original error is useless. An unnecessary catch clause can be confusing. (lint/complexity/noUselessCatch) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||||||||||||||||||||||||||||
| import { rssFeed } from '@/scripts/build-rss'; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| export async function runBuildRss() { | ||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||
| await rssFeed('blog', 'AsyncAPI Blog', 'Latest news and updates from AsyncAPI.', 'rss.xml'); | ||||||||||||||||||||||||||||||||
| } catch (err) { | ||||||||||||||||||||||||||||||||
| throw err; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+3
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Remove the unnecessary try-catch block. The try-catch block serves no purpose since it only rethrows the original error without adding any value. -export async function runBuildRss() {
- try {
- await rssFeed('blog', 'AsyncAPI Blog', 'Latest news and updates from AsyncAPI.', 'rss.xml');
- } catch (err) {
- throw err;
- }
-}
+export async function runBuildRss() {
+ await rssFeed('blog', 'AsyncAPI Blog', 'Latest news and updates from AsyncAPI.', 'rss.xml');
+}📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (1.9.4)[error] 7-7: The catch clause that only rethrows the original error is useless. An unnecessary catch clause can be confusing. (lint/complexity/noUselessCatch) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { buildTools } from "@/scripts/build-tools"; | ||
|
|
||
| import { dirname, resolve } from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
|
|
||
| const currentFilePath = fileURLToPath(import.meta.url); | ||
| const currentDirPath = dirname(currentFilePath); | ||
|
|
||
| export async function runBuildTools() { | ||
| try { | ||
| const automatedToolsPath = resolve(currentDirPath, '../../config', 'tools-automated.json'); | ||
| const manualToolsPath = resolve(currentDirPath, '../../config', 'tools-manual.json'); | ||
| const toolsPath = resolve(currentDirPath, '../../config', 'tools.json'); | ||
| const tagsPath = resolve(currentDirPath, '../../config', 'all-tags.json'); | ||
|
|
||
| await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); | ||
| } catch (error) { | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { buildCaseStudiesList } from '@/scripts/casestudies'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { dirname, resolve } from 'path'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { fileURLToPath } from 'url'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import fs from 'fs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const currentFilePath = fileURLToPath(import.meta.url); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const currentDirPath = dirname(currentFilePath); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const projectRoot = resolve(currentDirPath, '../../'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export async function runCaseStudies() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const caseStudyDirectory = resolve(projectRoot, 'config', 'casestudies'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!fs.existsSync(caseStudyDirectory)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error(`Directory does not exist: ${caseStudyDirectory}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const writeFilePath = resolve(projectRoot, 'config', 'case-studies.json'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await buildCaseStudiesList(caseStudyDirectory, writeFilePath); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+11
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve error handling consistency. Multiple issues with the error handling approach:
Apply this diff to improve the function: +import { logger } from '@/scripts/helpers/logger';
export async function runCaseStudies() {
- try {
- const caseStudyDirectory = resolve(projectRoot, 'config', 'casestudies');
- if (!fs.existsSync(caseStudyDirectory)) {
- console.error(`Directory does not exist: ${caseStudyDirectory}`);
- return;
- }
- const writeFilePath = resolve(projectRoot, 'config', 'case-studies.json');
- await buildCaseStudiesList(caseStudyDirectory, writeFilePath);
- } catch (error) {
- throw error;
- }
+ const caseStudyDirectory = resolve(projectRoot, 'config', 'casestudies');
+ if (!fs.existsSync(caseStudyDirectory)) {
+ logger.error(`Directory does not exist: ${caseStudyDirectory}`);
+ throw new Error(`Case studies directory not found: ${caseStudyDirectory}`);
+ }
+ const writeFilePath = resolve(projectRoot, 'config', 'case-studies.json');
+ await buildCaseStudiesList(caseStudyDirectory, writeFilePath);
}📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (1.9.4)[error] 20-20: The catch clause that only rethrows the original error is useless. An unnecessary catch clause can be confusing. (lint/complexity/noUselessCatch) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import inquirer from 'inquirer'; | ||
| import { ComposeBlog, ComposePromptType } from '@/scripts/compose'; | ||
| import { logger } from '@/scripts/helpers/logger'; | ||
|
|
||
| export async function runComposeBlog(): Promise<string> { | ||
| const answers: ComposePromptType = await inquirer.prompt([ | ||
| { | ||
| name: 'title', | ||
| message: 'Enter post title:', | ||
| type: 'input' | ||
| }, | ||
| { | ||
| name: 'excerpt', | ||
| message: 'Enter post excerpt:', | ||
| type: 'input' | ||
| }, | ||
| { | ||
| name: 'tags', | ||
| message: 'Any Tags? Separate them with , or leave empty if no tags.', | ||
| type: 'input' | ||
| }, | ||
| { | ||
| name: 'type', | ||
| message: 'Enter the post type:', | ||
| type: 'list', | ||
| choices: ['Communication', 'Community', 'Engineering', 'Marketing', 'Strategy', 'Video'] | ||
| }, | ||
| { | ||
| name: 'canonical', | ||
| message: 'Enter the canonical URL if any:', | ||
| type: 'input' | ||
| } | ||
| ]); | ||
|
|
||
| try { | ||
| return await ComposeBlog(answers); | ||
| } catch (error: any) { | ||
| logger.error(error); | ||
| if (error.isTtyError) { | ||
| logger.error("Prompt couldn't be rendered in the current environment"); | ||
| } else { | ||
| logger.error('Something went wrong, sorry!'); | ||
| } | ||
| throw error; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { dirname, resolve } from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
| import { writeJSON } from './utils/readAndWriteJson'; | ||
|
|
||
| /** | ||
| * Converts the YAML adopters configuration to a JSON file. | ||
| * | ||
| * This asynchronous function reads the adopters configuration from | ||
| * "config/adopters.yml" and converts its content to JSON format. It then writes | ||
| * the resulting JSON data to "adopters.json" in the configuration directory determined | ||
| * by resolving the current file's directory with "../../config". The operation is | ||
| * performed using the writeJSON utility. | ||
| * | ||
| * @returns {Promise<void>} Resolves when the adopters list has been built and written to JSON. | ||
| */ | ||
| export async function buildAdoptersList(): Promise<void> { | ||
| try { | ||
| const currentFilePath = fileURLToPath(import.meta.url); | ||
| const currentDirPath = dirname(currentFilePath); | ||
| await writeJSON('config/adopters.yml', resolve(currentDirPath, '../../config', 'adopters.json')); | ||
| } catch (error) { | ||
| throw error; | ||
| } | ||
| } |
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.
🛠️ Refactor suggestion
Remove the unnecessary try-catch block and fix formatting.
The try-catch block serves no purpose since it only rethrows the original error. Additionally, there's a formatting issue with missing space after
try.📝 Committable suggestion
🧰 Tools
🪛 Biome (1.9.4)
[error] 7-7: The catch clause that only rethrows the original error is useless.
An unnecessary catch clause can be confusing.
Unsafe fix: Remove the try/catch clause.
(lint/complexity/noUselessCatch)
🤖 Prompt for AI Agents