From 2935475b1175cdf0ff07c3b75f432d837224f846 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Sat, 16 Nov 2024 14:44:34 +0530 Subject: [PATCH 01/59] format scripts --- scripts/adopters/index.js | 7 +- scripts/build-docs.js | 113 ++++--- scripts/build-meetings.js | 10 +- scripts/build-newsroom-videos.js | 79 ++--- scripts/build-pages.js | 2 +- scripts/build-post-list.js | 214 ++++++++------ scripts/build-rss.js | 93 +++--- scripts/build-tools.js | 25 +- scripts/casestudies/index.js | 29 +- scripts/compose.js | 57 ++-- scripts/dashboard/build-dashboard.js | 87 ++++-- scripts/finance/index.js | 57 ++-- scripts/index.js | 6 +- scripts/markdown/check-markdown.js | 200 +++++++------ scripts/tools/categorylist.js | 139 +++++---- scripts/tools/combine-tools.js | 258 ++++++++-------- scripts/tools/extract-tools-github.js | 6 +- scripts/tools/tags-color.js | 346 +++++++++++----------- scripts/tools/tools-object.js | 104 ++++--- scripts/tools/tools-schema.json | 411 +++++++++++++------------- scripts/utils.js | 36 +-- scripts/utils/readAndWriteJson.js | 48 +-- 22 files changed, 1277 insertions(+), 1050 deletions(-) diff --git a/scripts/adopters/index.js b/scripts/adopters/index.js index 6a11697ad68f..ef6643802d62 100644 --- a/scripts/adopters/index.js +++ b/scripts/adopters/index.js @@ -1,6 +1,9 @@ const { resolve } = require('path'); -const writeJSON = require('../utils/readAndWriteJson.js') +const writeJSON = require('../utils/readAndWriteJson.js'); module.exports = async function buildAdoptersList() { - writeJSON('config/adopters.yml',resolve(__dirname, '../../config', 'adopters.json')); + writeJSON( + 'config/adopters.yml', + resolve(__dirname, '../../config', 'adopters.json'), + ); }; diff --git a/scripts/build-docs.js b/scripts/build-docs.js index ac47b6751cee..e1aff2f99cd1 100644 --- a/scripts/build-docs.js +++ b/scripts/build-docs.js @@ -1,26 +1,40 @@ -const sortBy = require('lodash/sortBy') +const sortBy = require('lodash/sortBy'); function buildNavTree(navItems) { try { const tree = { - 'welcome': { - item: { title: 'Welcome', weight: 0, isRootSection: true, isSection: true, rootSectionId: 'welcome', sectionWeight: 0, slug: '/docs' }, - children: {} - } - } + welcome: { + item: { + title: 'Welcome', + weight: 0, + isRootSection: true, + isSection: true, + rootSectionId: 'welcome', + sectionWeight: 0, + slug: '/docs', + }, + children: {}, + }, + }; //first we make sure that list of items lists main section items and then sub sections, documents last - const sortedItems = sortBy(navItems, ['isRootSection', 'weight', 'isSection']); + const sortedItems = sortBy(navItems, [ + 'isRootSection', + 'weight', + 'isSection', + ]); - sortedItems.forEach(item => { + sortedItems.forEach((item) => { //identify main sections if (item.isRootSection) { - tree[item.rootSectionId] = { item, children: {} } + tree[item.rootSectionId] = { item, children: {} }; } //identify subsections if (item.parent) { if (!tree[item.parent]) { - throw new Error(`Parent section ${item.parent} not found for item ${item.title}`); + throw new Error( + `Parent section ${item.parent} not found for item ${item.title}`, + ); } tree[item.parent].children[item.sectionId] = { item, children: [] }; } @@ -29,7 +43,10 @@ function buildNavTree(navItems) { if (item.sectionId) { let section = tree[item.rootSectionId]?.children[item.sectionId]; if (!section) { - tree[item.rootSectionId].children[item.sectionId] = { item, children: [] }; + tree[item.rootSectionId].children[item.sectionId] = { + item, + children: [], + }; } tree[item.rootSectionId].children[item.sectionId].children.push(item); } else { @@ -62,40 +79,39 @@ function buildNavTree(navItems) { // point in slug for specification subgroup to the latest specification version if (rootKey === 'reference' && key === 'specification') { - allChildren[key].item.href = allChildren[key].children.find(c => c.isPrerelease === undefined).slug; + allChildren[key].item.href = allChildren[key].children.find( + (c) => c.isPrerelease === undefined, + ).slug; } } } } return tree; - } catch (err) { throw new Error(`Failed to build navigation tree: ${err.message}`); } } -// A recursion function, works on the logic of Depth First Search to traverse all the root and child posts of the +// A recursion function, works on the logic of Depth First Search to traverse all the root and child posts of the // DocTree to get sequential order of the Doc Posts const convertDocPosts = (docObject) => { try { - let docsArray = [] + let docsArray = []; // certain entries in the DocPosts are either a parent to many posts or itself a post. - docsArray.push(docObject?.item || docObject) + docsArray.push(docObject?.item || docObject); if (docObject.children) { - let children = docObject.children + let children = docObject.children; Object.keys(children).forEach((child) => { - let docChildArray = convertDocPosts(children[child]) - docsArray = [...docsArray, ...docChildArray] - }) + let docChildArray = convertDocPosts(children[child]); + docsArray = [...docsArray, ...docChildArray]; + }); } - return docsArray - } - catch (err) { + return docsArray; + } catch (err) { throw new Error('Error in convertDocPosts:', err); } -} - +}; function addDocButtons(docPosts, treePosts) { let structuredPosts = []; @@ -115,56 +131,62 @@ function addDocButtons(docPosts, treePosts) { }); // Appending the content of welcome page of Docs from the posts.json - structuredPosts[0] = docPosts.filter(p => p.slug === '/docs')[0]; + structuredPosts[0] = docPosts.filter((p) => p.slug === '/docs')[0]; // Traversing the structuredPosts in order to add `nextPage` and `prevPage` details for each page let countDocPages = structuredPosts.length; structuredPosts = structuredPosts.map((post, index) => { - // post item specifying the root Section or sub-section in the docs are excluded as - // they doesn't comprise any Doc Page or content to be shown in website. + // post item specifying the root Section or sub-section in the docs are excluded as + // they doesn't comprise any Doc Page or content to be shown in website. if (post?.isRootSection || post?.isSection || index == 0) { - if (post?.isRootSection || index == 0) - rootSections.push(post.title) - return post + if (post?.isRootSection || index == 0) rootSections.push(post.title); + return post; } - let nextPage = {}, prevPage = {} + let nextPage = {}, + prevPage = {}; let docPost = post; // checks whether the next page for the current docPost item exists or not if (index + 1 < countDocPages) { // checks whether the next item inside structuredPosts is a rootElement or a sectionElement // if yes, it goes again to a next to next item in structuredPosts to link the nextPage - if (!structuredPosts[index + 1].isRootElement && !structuredPosts[index + 1].isSection) { + if ( + !structuredPosts[index + 1].isRootElement && + !structuredPosts[index + 1].isSection + ) { nextPage = { title: structuredPosts[index + 1].title, - href: structuredPosts[index + 1].slug - } + href: structuredPosts[index + 1].slug, + }; } else { nextPage = { title: `${structuredPosts[index + 1].title} - ${structuredPosts[index + 2].title}`, - href: structuredPosts[index + 2].slug - } + href: structuredPosts[index + 2].slug, + }; } - docPost = { ...docPost, nextPage } + docPost = { ...docPost, nextPage }; } // checks whether the previous page for the current docPost item exists or not if (index > 0) { // checks whether the previous item inside structuredPosts is a rootElement or a sectionElement // if yes, it goes again to a next previous item in structuredPosts to link the prevPage - if (!structuredPosts[index - 1]?.isRootElement && !structuredPosts[index - 1]?.isSection) { + if ( + !structuredPosts[index - 1]?.isRootElement && + !structuredPosts[index - 1]?.isSection + ) { prevPage = { title: structuredPosts[index - 1].title, - href: structuredPosts[index - 1].slug - } - docPost = { ...docPost, prevPage } + href: structuredPosts[index - 1].slug, + }; + docPost = { ...docPost, prevPage }; } else { // additonal check for the first page of Docs so that it doesn't give any Segementation fault if (index - 2 >= 0) { prevPage = { title: `${structuredPosts[index - 1]?.isRootSection ? rootSections[rootSections.length - 2] : rootSections[rootSections.length - 1]} - ${structuredPosts[index - 2].title}`, - href: structuredPosts[index - 2].slug + href: structuredPosts[index - 2].slug, }; docPost = { ...docPost, prevPage }; } @@ -172,11 +194,10 @@ function addDocButtons(docPosts, treePosts) { } return docPost; }); - } catch (err) { - throw new Error("An error occurred while adding doc buttons:", err); + throw new Error('An error occurred while adding doc buttons:', err); } return structuredPosts; } -module.exports = { buildNavTree, addDocButtons, convertDocPosts } \ No newline at end of file +module.exports = { buildNavTree, addDocButtons, convertDocPosts }; diff --git a/scripts/build-meetings.js b/scripts/build-meetings.js index ee95803d9d44..cc56c0d026b8 100644 --- a/scripts/build-meetings.js +++ b/scripts/build-meetings.js @@ -9,11 +9,12 @@ async function buildMeetings(writePath) { try { auth = new google.auth.GoogleAuth({ scopes: ['https://www.googleapis.com/auth/calendar'], - credentials: process.env.CALENDAR_SERVICE_ACCOUNT ? JSON.parse(process.env.CALENDAR_SERVICE_ACCOUNT) : undefined, + credentials: process.env.CALENDAR_SERVICE_ACCOUNT + ? JSON.parse(process.env.CALENDAR_SERVICE_ACCOUNT) + : undefined, }); calendar = google.calendar({ version: 'v3', auth }); - } catch (err) { throw new Error(`Authentication failed: ${err.message}`); } @@ -24,10 +25,10 @@ async function buildMeetings(writePath) { //cron job runs this always on midnight const currentTime = new Date(Date.now()).toISOString(); const timeMin = new Date( - Date.parse(currentTime) - 100 * 24 * 60 * 60 * 1000 + Date.parse(currentTime) - 100 * 24 * 60 * 60 * 1000, ).toISOString(); const timeMax = new Date( - Date.parse(currentTime) + 30 * 24 * 60 * 60 * 1000 + Date.parse(currentTime) + 30 * 24 * 60 * 60 * 1000, ).toISOString(); const eventsList = await calendar.events.list({ @@ -53,7 +54,6 @@ async function buildMeetings(writePath) { console.log('The following events got fetched', eventsForHuman); writeFileSync(writePath, eventsForHuman); - } catch (err) { throw new Error(`Failed to fetch or process events: ${err.message}`); } diff --git a/scripts/build-newsroom-videos.js b/scripts/build-newsroom-videos.js index 383927765d36..496eba2de769 100644 --- a/scripts/build-newsroom-videos.js +++ b/scripts/build-newsroom-videos.js @@ -3,49 +3,52 @@ const { resolve } = require('path'); const fetch = require('node-fetch-2'); async function buildNewsroomVideos(writePath) { - try { - const response = await fetch('https://youtube.googleapis.com/youtube/v3/search?' + new URLSearchParams({ - key: process.env.YOUTUBE_TOKEN, - part: 'snippet', - channelId: 'UCIz9zGwDLbrYQcDKVXdOstQ', - eventType: 'completed', - type: 'video', - order: 'Date', - maxResults: 5, - })); - - if (!response.ok) { - throw new Error(`HTTP error! with status code: ${response.status}`); - } - - const data = await response.json(); - console.log(data); - - if (!data.items || !Array.isArray(data.items)) { - throw new Error('Invalid data structure received from YouTube API'); - } - - const videoDataItems = data.items.map((video) => ({ - image_url: video.snippet.thumbnails.high.url, - title: video.snippet.title, - description: video.snippet.description, - videoId: video.id.videoId, - })); - - const videoData = JSON.stringify(videoDataItems, null, ' '); - console.log('The following are the Newsroom Youtube videos: ', videoData); - - writeFileSync(writePath, videoData); - - return videoData; - } catch (err) { - throw new Error(`Failed to build newsroom videos: ${err.message}`); + try { + const response = await fetch( + 'https://youtube.googleapis.com/youtube/v3/search?' + + new URLSearchParams({ + key: process.env.YOUTUBE_TOKEN, + part: 'snippet', + channelId: 'UCIz9zGwDLbrYQcDKVXdOstQ', + eventType: 'completed', + type: 'video', + order: 'Date', + maxResults: 5, + }), + ); + + if (!response.ok) { + throw new Error(`HTTP error! with status code: ${response.status}`); } + + const data = await response.json(); + console.log(data); + + if (!data.items || !Array.isArray(data.items)) { + throw new Error('Invalid data structure received from YouTube API'); + } + + const videoDataItems = data.items.map((video) => ({ + image_url: video.snippet.thumbnails.high.url, + title: video.snippet.title, + description: video.snippet.description, + videoId: video.id.videoId, + })); + + const videoData = JSON.stringify(videoDataItems, null, ' '); + console.log('The following are the Newsroom Youtube videos: ', videoData); + + writeFileSync(writePath, videoData); + + return videoData; + } catch (err) { + throw new Error(`Failed to build newsroom videos: ${err.message}`); + } } /* istanbul ignore next */ if (require.main === module) { - buildNewsroomVideos(resolve(__dirname, '../config', 'newsroom_videos.json')) + buildNewsroomVideos(resolve(__dirname, '../config', 'newsroom_videos.json')); } module.exports = { buildNewsroomVideos }; diff --git a/scripts/build-pages.js b/scripts/build-pages.js index 48b3553e96b2..287d44f046b0 100644 --- a/scripts/build-pages.js +++ b/scripts/build-pages.js @@ -57,4 +57,4 @@ function copyAndRenameFiles(srcDir, targetDir) { copyAndRenameFiles(SRC_DIR, TARGET_DIR); -module.exports = {copyAndRenameFiles,capitalizeJsxTags} \ No newline at end of file +module.exports = { copyAndRenameFiles, capitalizeJsxTags }; diff --git a/scripts/build-post-list.js b/scripts/build-post-list.js index 288d7dc0c54e..dc249c6e2a43 100644 --- a/scripts/build-post-list.js +++ b/scripts/build-post-list.js @@ -1,161 +1,201 @@ -const { readdirSync, statSync, existsSync, readFileSync, writeFileSync } = require('fs') -const { resolve, basename } = require('path') -const frontMatter = require('gray-matter') -const toc = require('markdown-toc') -const { slugify } = require('markdown-toc/lib/utils') -const readingTime = require('reading-time') -const { markdownToTxt } = require('markdown-to-txt') -const { buildNavTree, addDocButtons } = require('./build-docs') +const { + readdirSync, + statSync, + existsSync, + readFileSync, + writeFileSync, +} = require('fs'); +const { resolve, basename } = require('path'); +const frontMatter = require('gray-matter'); +const toc = require('markdown-toc'); +const { slugify } = require('markdown-toc/lib/utils'); +const readingTime = require('reading-time'); +const { markdownToTxt } = require('markdown-to-txt'); +const { buildNavTree, addDocButtons } = require('./build-docs'); -let specWeight = 100 +let specWeight = 100; const result = { docs: [], blog: [], about: [], - docsTree: {} -} -const releaseNotes = [] -const basePath = 'pages' + docsTree: {}, +}; +const releaseNotes = []; +const basePath = 'pages'; const postDirectories = [ // order of these directories is important, as the blog should come before docs, to create a list of available release notes, which will later be used to release-note-link for spec docs [`${basePath}/blog`, '/blog'], [`${basePath}/docs`, '/docs'], - [`${basePath}/about`, '/about'] + [`${basePath}/about`, '/about'], ]; const addItem = (details) => { - if(details.slug.startsWith('/docs')) - result["docs"].push(details) - else if(details.slug.startsWith('/blog')) - result["blog"].push(details) - else if(details.slug.startsWith('/about')) - result["about"].push(details) - else {} -} + if (details.slug.startsWith('/docs')) result['docs'].push(details); + else if (details.slug.startsWith('/blog')) result['blog'].push(details); + else if (details.slug.startsWith('/about')) result['about'].push(details); + else { + } +}; module.exports = async function buildPostList() { - walkDirectories(postDirectories, result) - const treePosts = buildNavTree(result["docs"].filter((p) => p.slug.startsWith('/docs/'))) - result["docsTree"] = treePosts - result["docs"] = addDocButtons(result["docs"], treePosts) + walkDirectories(postDirectories, result); + const treePosts = buildNavTree( + result['docs'].filter((p) => p.slug.startsWith('/docs/')), + ); + result['docsTree'] = treePosts; + result['docs'] = addDocButtons(result['docs'], treePosts); if (process.env.NODE_ENV === 'production') { // console.log(inspect(result, { depth: null, colors: true })) } - writeFileSync(resolve(__dirname, '..', 'config', 'posts.json'), JSON.stringify(result, null, ' ')) -} + writeFileSync( + resolve(__dirname, '..', 'config', 'posts.json'), + JSON.stringify(result, null, ' '), + ); +}; -function walkDirectories(directories, result, sectionWeight = 0, sectionTitle, sectionId, rootSectionId) { +function walkDirectories( + directories, + result, + sectionWeight = 0, + sectionTitle, + sectionId, + rootSectionId, +) { for (let dir of directories) { - let directory = dir[0] - let sectionSlug = dir[1] || '' + let directory = dir[0]; + let sectionSlug = dir[1] || ''; let files = readdirSync(directory); for (let file of files) { - let details - const fileName = [directory, file].join('/') - const fileNameWithSection = [fileName, '_section.mdx'].join('/') - const slug = fileName.replace(new RegExp(`^${basePath}`), '') + let details; + const fileName = [directory, file].join('/'); + const fileNameWithSection = [fileName, '_section.mdx'].join('/'); + const slug = fileName.replace(new RegExp(`^${basePath}`), ''); const slugElements = slug.split('/'); if (isDirectory(fileName)) { if (existsSync(fileNameWithSection)) { // Passing a second argument to frontMatter disables cache. See https://github.com/asyncapi/website/issues/1057 - details = frontMatter(readFileSync(fileNameWithSection, 'utf-8'), {}).data - details.title = details.title || capitalize(basename(fileName)) + details = frontMatter( + readFileSync(fileNameWithSection, 'utf-8'), + {}, + ).data; + details.title = details.title || capitalize(basename(fileName)); } else { details = { title: capitalize(basename(fileName)), - } + }; } - details.isSection = true + details.isSection = true; if (slugElements.length > 3) { - details.parent = slugElements[slugElements.length - 2] - details.sectionId = slugElements[slugElements.length - 1] + details.parent = slugElements[slugElements.length - 2]; + details.sectionId = slugElements[slugElements.length - 1]; } if (!details.parent) { - details.isRootSection = true - details.rootSectionId = slugElements[slugElements.length - 1] + details.isRootSection = true; + details.rootSectionId = slugElements[slugElements.length - 1]; } - details.sectionWeight = sectionWeight - details.slug = slug - addItem(details) - const rootId = details.parent || details.rootSectionId - walkDirectories([[fileName, slug]], result, details.weight, details.title, details.sectionId, rootId) + details.sectionWeight = sectionWeight; + details.slug = slug; + addItem(details); + const rootId = details.parent || details.rootSectionId; + walkDirectories( + [[fileName, slug]], + result, + details.weight, + details.title, + details.sectionId, + rootId, + ); } else if (file.endsWith('.mdx') && !fileName.endsWith('/_section.mdx')) { - const fileContent = readFileSync(fileName, 'utf-8') + const fileContent = readFileSync(fileName, 'utf-8'); // Passing a second argument to frontMatter disables cache. See https://github.com/asyncapi/website/issues/1057 - const { data, content } = frontMatter(fileContent, {}) - details = data - details.toc = toc(content, { slugify: slugifyToC }).json - details.readingTime = Math.ceil(readingTime(content).minutes) - details.excerpt = details.excerpt || markdownToTxt(content).substr(0, 200) - details.sectionSlug = sectionSlug || slug.replace(/\.mdx$/, '') - details.sectionWeight = sectionWeight - details.sectionTitle = sectionTitle - details.sectionId = sectionId - details.rootSectionId = rootSectionId - details.id = fileName - details.isIndex = fileName.endsWith('/index.mdx') - details.slug = details.isIndex ? sectionSlug : slug.replace(/\.mdx$/, '') - if(details.slug.includes('/reference/specification/') && !details.title) { - const fileBaseName = basename(data.slug) // ex. v2.0.0 | v2.1.0-next-spec.1 - const fileName = fileBaseName.split('-')[0] // v2.0.0 | v2.1.0 - details.weight = specWeight-- + const { data, content } = frontMatter(fileContent, {}); + details = data; + details.toc = toc(content, { slugify: slugifyToC }).json; + details.readingTime = Math.ceil(readingTime(content).minutes); + details.excerpt = + details.excerpt || markdownToTxt(content).substr(0, 200); + details.sectionSlug = sectionSlug || slug.replace(/\.mdx$/, ''); + details.sectionWeight = sectionWeight; + details.sectionTitle = sectionTitle; + details.sectionId = sectionId; + details.rootSectionId = rootSectionId; + details.id = fileName; + details.isIndex = fileName.endsWith('/index.mdx'); + details.slug = details.isIndex + ? sectionSlug + : slug.replace(/\.mdx$/, ''); + if ( + details.slug.includes('/reference/specification/') && + !details.title + ) { + const fileBaseName = basename(data.slug); // ex. v2.0.0 | v2.1.0-next-spec.1 + const fileName = fileBaseName.split('-')[0]; // v2.0.0 | v2.1.0 + details.weight = specWeight--; if (fileName.startsWith('v')) { - details.title = capitalize(fileName.slice(1)) + details.title = capitalize(fileName.slice(1)); } else { - details.title = capitalize(fileName) + details.title = capitalize(fileName); } - if(releaseNotes.includes(details.title)){ - details.releaseNoteLink = `/blog/release-notes-${details.title}` + if (releaseNotes.includes(details.title)) { + details.releaseNoteLink = `/blog/release-notes-${details.title}`; } - if (fileBaseName.includes('next-spec') || fileBaseName.includes('next-major-spec')) { - details.isPrerelease = true + if ( + fileBaseName.includes('next-spec') || + fileBaseName.includes('next-major-spec') + ) { + details.isPrerelease = true; // this need to be separate because the `-` in "Pre-release" will get removed by `capitalize()` function - details.title += " (Pre-release)" + details.title += ' (Pre-release)'; } if (fileBaseName.includes('explorer')) { - details.title += " - Explorer" + details.title += ' - Explorer'; } } // To create a list of available ReleaseNotes list, which will be used to add details.releaseNoteLink attribute. - if(file.startsWith("release-notes") && dir[1] === "/blog"){ - const fileName_without_extension = file.slice(0,-4) + if (file.startsWith('release-notes') && dir[1] === '/blog') { + const fileName_without_extension = file.slice(0, -4); // removes the file extension. For example, release-notes-2.1.0.md -> release-notes-2.1.0 - const version = fileName_without_extension.slice(fileName_without_extension.lastIndexOf("-")+1) + const version = fileName_without_extension.slice( + fileName_without_extension.lastIndexOf('-') + 1, + ); // gets the version from the name of the releaseNote .md file (from /blog). For example, version = 2.1.0 if fileName_without_extension = release-notes-2.1.0 - releaseNotes.push(version) + releaseNotes.push(version); // releaseNotes is the list of all available releaseNotes } - addItem(details) + addItem(details); } } } } function slugifyToC(str) { - let slug + let slug; // Try to match heading ids like {# myHeadingId} - const headingIdMatch = str.match(/[\s]?\{\#([\w\d\-_]+)\}/) + const headingIdMatch = str.match(/[\s]?\{\#([\w\d\-_]+)\}/); if (headingIdMatch && headingIdMatch.length >= 2) { - slug = headingIdMatch[1] + slug = headingIdMatch[1]; } else { // Try to match heading ids like {} - const anchorTagMatch = str.match(/[\s]*= 2) slug = anchorTagMatch[1] + const anchorTagMatch = str.match(/[\s]*= 2) slug = anchorTagMatch[1]; } - return slug || slugify(str, { firsth1: true, maxdepth: 6 }) + return slug || slugify(str, { firsth1: true, maxdepth: 6 }); } function isDirectory(dir) { - return statSync(dir).isDirectory() + return statSync(dir).isDirectory(); } function capitalize(text) { - return text.split(/[\s\-]/g).map(word => `${word[0].toUpperCase()}${word.substr(1)}`).join(' ') + return text + .split(/[\s\-]/g) + .map((word) => `${word[0].toUpperCase()}${word.substr(1)}`) + .join(' '); } diff --git a/scripts/build-rss.js b/scripts/build-rss.js index 673da1398fe0..46c668119c6a 100644 --- a/scripts/build-rss.js +++ b/scripts/build-rss.js @@ -1,26 +1,25 @@ -const fs = require('fs').promises -const json2xml = require('jgexml/json2xml') +const fs = require('fs').promises; +const json2xml = require('jgexml/json2xml'); function getAllPosts() { return require('../config/posts.json'); } function clean(s) { - s = s.split('<span>').join('') - s = s.split('&').join('&') - s = s.split(''').join("'") - s = s.split('<').join('<') - s = s.split('>').join('>') - s = s.split('"').join('"') - return s + s = s.split('<span>').join(''); + s = s.split('&').join('&'); + s = s.split(''').join("'"); + s = s.split('<').join('<'); + s = s.split('>').join('>'); + s = s.split('"').join('"'); + return s; } module.exports = async function rssFeed(type, title, desc, outputPath) { try { - - let posts = getAllPosts()[`${type}`] - const missingDatePosts = posts.filter(post => !post.date); - posts = posts.filter(post => post.date); + let posts = getAllPosts()[`${type}`]; + const missingDatePosts = posts.filter((post) => !post.date); + posts = posts.filter((post) => post.date); posts.sort((i1, i2) => { const i1Date = new Date(i1.date); const i2Date = new Date(i2.date); @@ -30,37 +29,41 @@ module.exports = async function rssFeed(type, title, desc, outputPath) { }); if (missingDatePosts.length > 0) { - throw new Error(`Missing date in posts: ${missingDatePosts.map(p => p.title || p.slug).join(', ')}`); + throw new Error( + `Missing date in posts: ${missingDatePosts.map((p) => p.title || p.slug).join(', ')}`, + ); } - const base = 'https://www.asyncapi.com' + const base = 'https://www.asyncapi.com'; const tracking = '?utm_source=rss'; - const feed = {} - const rss = {} - rss['@version'] = '2.0' - rss["@xmlns:atom"] = 'http://www.w3.org/2005/Atom' - rss.channel = {} - rss.channel.title = title - rss.channel.link = `${base}/${outputPath}` - rss.channel["atom:link"] = {} - rss.channel["atom:link"]["@rel"] = 'self' - rss.channel["atom:link"]["@href"] = rss.channel.link - rss.channel["atom:link"]["@type"] = 'application/rss+xml' - rss.channel.description = desc + const feed = {}; + const rss = {}; + rss['@version'] = '2.0'; + rss['@xmlns:atom'] = 'http://www.w3.org/2005/Atom'; + rss.channel = {}; + rss.channel.title = title; + rss.channel.link = `${base}/${outputPath}`; + rss.channel['atom:link'] = {}; + rss.channel['atom:link']['@rel'] = 'self'; + rss.channel['atom:link']['@href'] = rss.channel.link; + rss.channel['atom:link']['@type'] = 'application/rss+xml'; + rss.channel.description = desc; rss.channel.language = 'en-gb'; rss.channel.copyright = 'Made with :love: by the AsyncAPI Initiative.'; - rss.channel.webMaster = 'info@asyncapi.io (AsyncAPI Initiative)' - rss.channel.pubDate = new Date().toUTCString() - rss.channel.generator = 'next.js' - rss.channel.item = [] + rss.channel.webMaster = 'info@asyncapi.io (AsyncAPI Initiative)'; + rss.channel.pubDate = new Date().toUTCString(); + rss.channel.generator = 'next.js'; + rss.channel.item = []; - const invalidPosts = posts.filter(post => - !post.title || !post.slug || !post.excerpt || !post.date + const invalidPosts = posts.filter( + (post) => !post.title || !post.slug || !post.excerpt || !post.date, ); if (invalidPosts.length > 0) { - throw new Error(`Missing required fields in posts: ${invalidPosts.map(p => p.title || p.slug).join(', ')}`); + throw new Error( + `Missing required fields in posts: ${invalidPosts.map((p) => p.title || p.slug).join(', ')}`, + ); } for (let post of posts) { @@ -75,25 +78,25 @@ module.exports = async function rssFeed(type, title, desc, outputPath) { link, category: type, guid, - pubDate + pubDate, }; if (post.cover) { const enclosure = {}; - enclosure["@url"] = base + post.cover; - enclosure["@length"] = 15026; // dummy value, anything works - enclosure["@type"] = 'image/jpeg'; - if (typeof enclosure["@url"] === 'string') { - let tmp = enclosure["@url"].toLowerCase(); - if (tmp.indexOf('.png') >= 0) enclosure["@type"] = 'image/png'; - if (tmp.indexOf('.svg') >= 0) enclosure["@type"] = 'image/svg+xml'; - if (tmp.indexOf('.webp') >= 0) enclosure["@type"] = 'image/webp'; + enclosure['@url'] = base + post.cover; + enclosure['@length'] = 15026; // dummy value, anything works + enclosure['@type'] = 'image/jpeg'; + if (typeof enclosure['@url'] === 'string') { + let tmp = enclosure['@url'].toLowerCase(); + if (tmp.indexOf('.png') >= 0) enclosure['@type'] = 'image/png'; + if (tmp.indexOf('.svg') >= 0) enclosure['@type'] = 'image/svg+xml'; + if (tmp.indexOf('.webp') >= 0) enclosure['@type'] = 'image/webp'; } item.enclosure = enclosure; } - rss.channel.item.push(item) + rss.channel.item.push(item); } - feed.rss = rss + feed.rss = rss; const xml = json2xml.getXml(feed, '@', '', 2); await fs.writeFile(`./public/${outputPath}`, xml, 'utf8'); diff --git a/scripts/build-tools.js b/scripts/build-tools.js index c5cce74a7cb1..30404a2d015f 100644 --- a/scripts/build-tools.js +++ b/scripts/build-tools.js @@ -4,14 +4,27 @@ const { combineTools } = require('./tools/combine-tools'); const fs = require('fs-extra'); const { resolve } = require('path'); -const buildTools = async (automatedToolsPath, manualToolsPath, toolsPath, tagsPath) => { +const buildTools = async ( + automatedToolsPath, + manualToolsPath, + toolsPath, + tagsPath, +) => { try { let githubExtractData = await getData(); let automatedTools = await convertTools(githubExtractData); - await fs.writeFile(automatedToolsPath, JSON.stringify(automatedTools, null, ' ')); + await fs.writeFile( + automatedToolsPath, + JSON.stringify(automatedTools, null, ' '), + ); - await combineTools(automatedTools, require(manualToolsPath), toolsPath, tagsPath); + await combineTools( + automatedTools, + require(manualToolsPath), + toolsPath, + tagsPath, + ); } catch (err) { throw new Error(`An error occurred while building tools: ${err.message}`); } @@ -19,7 +32,11 @@ const buildTools = async (automatedToolsPath, manualToolsPath, toolsPath, tagsPa /* istanbul ignore next */ if (require.main === module) { - const automatedToolsPath = resolve(__dirname, '../config', 'tools-automated.json'); + 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'); diff --git a/scripts/casestudies/index.js b/scripts/casestudies/index.js index 77695e06fd38..3ff9e415f525 100644 --- a/scripts/casestudies/index.js +++ b/scripts/casestudies/index.js @@ -1,19 +1,22 @@ const { readdir, writeFile, readFile } = require('fs').promises; const { convertToJson } = require('../../scripts/utils'); -module.exports = async function buildCaseStudiesList(dirWithCaseStudy, writeFilePath) { - try { - let files = await readdir(dirWithCaseStudy); - let caseStudiesList = []; - for (let file of files) { - const caseStudyFileName = [dirWithCaseStudy, file].join('/'); - const caseStudyContent = await readFile(caseStudyFileName, 'utf-8'); - const jsonContent = convertToJson(caseStudyContent); +module.exports = async function buildCaseStudiesList( + dirWithCaseStudy, + writeFilePath, +) { + try { + let files = await readdir(dirWithCaseStudy); + let caseStudiesList = []; + for (let file of files) { + const caseStudyFileName = [dirWithCaseStudy, file].join('/'); + const caseStudyContent = await readFile(caseStudyFileName, 'utf-8'); + const jsonContent = convertToJson(caseStudyContent); - caseStudiesList.push(jsonContent); - await writeFile(writeFilePath, JSON.stringify(caseStudiesList)) - } - } catch (err) { - throw new Error(err); + caseStudiesList.push(jsonContent); + await writeFile(writeFilePath, JSON.stringify(caseStudiesList)); } + } catch (err) { + throw new Error(err); + } }; diff --git a/scripts/compose.js b/scripts/compose.js index 8c4f0e3a4a36..00d262019428 100644 --- a/scripts/compose.js +++ b/scripts/compose.js @@ -2,25 +2,25 @@ * Script based on https://github.com/timlrx/tailwind-nextjs-starter-blog/blob/master/scripts/compose.js */ -const fs = require('fs') -const inquirer = require('inquirer') -const dedent = require('dedent') -const moment = require('moment') +const fs = require('fs'); +const inquirer = require('inquirer'); +const dedent = require('dedent'); +const moment = require('moment'); const genFrontMatter = (answers) => { - let d = new Date() + let d = new Date(); const date = [ d.getFullYear(), ('0' + (d.getMonth() + 1)).slice(-2), ('0' + d.getDate()).slice(-2), - ].join('-') - const tagArray = answers.tags.split(',') - tagArray.forEach((tag, index) => (tagArray[index] = tag.trim())) - const tags = "'" + tagArray.join("','") + "'" + ].join('-'); + const tagArray = answers.tags.split(','); + tagArray.forEach((tag, index) => (tagArray[index] = tag.trim())); + const tags = "'" + tagArray.join("','") + "'"; let frontMatter = dedent`--- title: ${answers.title ? answers.title : 'Untitled'} - date: ${moment().format("YYYY-MM-DDTh:mm:ssZ")} + date: ${moment().format('YYYY-MM-DDTh:mm:ssZ')} type: ${answers.type} canonical: ${answers.canonical ? answers.canonical : ''} tags: [${answers.tags ? tags : ''}] @@ -90,12 +90,12 @@ const genFrontMatter = (answers) => {
- ` + `; - frontMatter = frontMatter + '\n---' + frontMatter = frontMatter + '\n---'; - return frontMatter -} + return frontMatter; +}; inquirer .prompt([ @@ -118,7 +118,14 @@ inquirer name: 'type', message: 'Enter the post type:', type: 'list', - choices: ['Communication', 'Community', 'Engineering', 'Marketing', 'Strategy', 'Video'], + choices: [ + 'Communication', + 'Community', + 'Engineering', + 'Marketing', + 'Strategy', + 'Video', + ], }, { name: 'canonical', @@ -132,22 +139,22 @@ inquirer .toLowerCase() .replace(/[^a-zA-Z0-9 ]/g, '') .replace(/ /g, '-') - .replace(/-+/g, '-') - const frontMatter = genFrontMatter(answers) - const filePath = `pages/blog/${fileName ? fileName : 'untitled'}.md` + .replace(/-+/g, '-'); + const frontMatter = genFrontMatter(answers); + const filePath = `pages/blog/${fileName ? fileName : 'untitled'}.md`; fs.writeFile(filePath, frontMatter, { flag: 'wx' }, (err) => { if (err) { - throw err + throw err; } else { - console.log(`Blog post generated successfully at ${filePath}`) + console.log(`Blog post generated successfully at ${filePath}`); } - }) + }); }) .catch((error) => { - console.error(error) + console.error(error); if (error.isTtyError) { - console.log("Prompt couldn't be rendered in the current environment") + console.log("Prompt couldn't be rendered in the current environment"); } else { - console.log('Something went wrong, sorry!') + console.log('Something went wrong, sorry!'); } - }) + }); diff --git a/scripts/dashboard/build-dashboard.js b/scripts/dashboard/build-dashboard.js index c20be204e87b..cb07d85c2f5f 100644 --- a/scripts/dashboard/build-dashboard.js +++ b/scripts/dashboard/build-dashboard.js @@ -20,8 +20,8 @@ async function getDiscussions(query, pageSize, endCursor = null) { first: pageSize, after: endCursor, headers: { - authorization: `token ${process.env.GITHUB_TOKEN}` - } + authorization: `token ${process.env.GITHUB_TOKEN}`, + }, }); if (result.rateLimit.remaining <= 100) { @@ -30,7 +30,7 @@ async function getDiscussions(query, pageSize, endCursor = null) { `cost = ${result.rateLimit.cost}`, `limit = ${result.rateLimit.limit}`, `remaining = ${result.rateLimit.remaining}`, - `resetAt = ${result.rateLimit.resetAt}` + `resetAt = ${result.rateLimit.resetAt}`, ); } @@ -41,7 +41,9 @@ async function getDiscussions(query, pageSize, endCursor = null) { if (!hasNextPage) { return result.search.nodes; } - return result.search.nodes.concat(await getDiscussions(query, pageSize, result.search.pageInfo.endCursor)); + return result.search.nodes.concat( + await getDiscussions(query, pageSize, result.search.pageInfo.endCursor), + ); } catch (e) { console.error(e); return Promise.reject(e); @@ -50,12 +52,15 @@ async function getDiscussions(query, pageSize, endCursor = null) { async function getDiscussionByID(isPR, id) { try { - const result = await graphql(isPR ? Queries.pullRequestById : Queries.issueById, { - id, - headers: { - authorization: `token ${process.env.GITHUB_TOKEN}` - } - }); + const result = await graphql( + isPR ? Queries.pullRequestById : Queries.issueById, + { + id, + headers: { + authorization: `token ${process.env.GITHUB_TOKEN}`, + }, + }, + ); return result; } catch (e) { @@ -70,19 +75,28 @@ async function processHotDiscussions(batch) { try { const isPR = discussion.__typename === 'PullRequest'; if (discussion.comments.pageInfo.hasNextPage) { - const fetchedDiscussion = await getDiscussionByID(isPR, discussion.id); + const fetchedDiscussion = await getDiscussionByID( + isPR, + discussion.id, + ); discussion = fetchedDiscussion.node; } const interactionsCount = discussion.reactions.totalCount + discussion.comments.totalCount + - discussion.comments.nodes.reduce((acc, curr) => acc + curr.reactions.totalCount, 0); + discussion.comments.nodes.reduce( + (acc, curr) => acc + curr.reactions.totalCount, + 0, + ); const finalInteractionsCount = isPR ? interactionsCount + - discussion.reviews.totalCount + - discussion.reviews.nodes.reduce((acc, curr) => acc + curr.comments.totalCount, 0) + discussion.reviews.totalCount + + discussion.reviews.nodes.reduce( + (acc, curr) => acc + curr.comments.totalCount, + 0, + ) : interactionsCount; return { @@ -94,13 +108,17 @@ async function processHotDiscussions(batch) { resourcePath: discussion.resourcePath, repo: `asyncapi/${discussion.repository.name}`, labels: discussion.labels ? discussion.labels.nodes : [], - score: finalInteractionsCount / (monthsSince(discussion.timelineItems.updatedAt) + 2) ** 1.8 + score: + finalInteractionsCount / + (monthsSince(discussion.timelineItems.updatedAt) + 2) ** 1.8, }; } catch (e) { - console.error(`there were some issues while parsing this item: ${JSON.stringify(discussion)}`); + console.error( + `there were some issues while parsing this item: ${JSON.stringify(discussion)}`, + ); throw e; } - }) + }), ); } @@ -116,7 +134,9 @@ async function getHotDiscussions(discussions) { } result.sort((ElemA, ElemB) => ElemB.score - ElemA.score); - const filteredResult = result.filter((issue) => issue.author !== 'asyncapi-bot'); + const filteredResult = result.filter( + (issue) => issue.author !== 'asyncapi-bot', + ); return filteredResult.slice(0, 12); } @@ -126,7 +146,7 @@ async function writeToFile(content, writePath) { } catch (error) { console.error('Failed to write dashboard data:', { error: error.message, - writePath + writePath, }); throw error; } @@ -142,13 +162,17 @@ async function mapGoodFirstIssues(issues) { author: issue.author.login, area: getLabel(issue, 'area/') || 'Unknown', labels: issue.labels.nodes.filter( - (label) => !label.name.startsWith('area/') && !label.name.startsWith('good first issue') - ) + (label) => + !label.name.startsWith('area/') && + !label.name.startsWith('good first issue'), + ), })); } function getLabel(issue, filter) { - const result = issue.labels.nodes.find((label) => label.name.startsWith(filter)); + const result = issue.labels.nodes.find((label) => + label.name.startsWith(filter), + ); return result?.name.split('/')[1]; } @@ -163,11 +187,14 @@ async function start(writePath) { try { const issues = await getDiscussions(Queries.hotDiscussionsIssues, 20); const PRs = await getDiscussions(Queries.hotDiscussionsPullRequests, 20); - const rawGoodFirstIssues = await getDiscussions(Queries.goodFirstIssues, 20); + const rawGoodFirstIssues = await getDiscussions( + Queries.goodFirstIssues, + 20, + ); const discussions = issues.concat(PRs); const [hotDiscussions, goodFirstIssues] = await Promise.all([ getHotDiscussions(discussions), - mapGoodFirstIssues(rawGoodFirstIssues) + mapGoodFirstIssues(rawGoodFirstIssues), ]); return await writeToFile({ hotDiscussions, goodFirstIssues }, writePath); } catch (e) { @@ -181,4 +208,14 @@ if (require.main === module) { start(resolve(__dirname, '..', '..', 'dashboard.json')); } -module.exports = { getLabel, monthsSince, mapGoodFirstIssues, getHotDiscussions, getDiscussionByID, getDiscussions, writeToFile, start, processHotDiscussions }; +module.exports = { + getLabel, + monthsSince, + mapGoodFirstIssues, + getHotDiscussions, + getDiscussionByID, + getDiscussions, + writeToFile, + start, + processHotDiscussions, +}; diff --git a/scripts/finance/index.js b/scripts/finance/index.js index 3f4a5edcfb6e..af3cf0a80f60 100644 --- a/scripts/finance/index.js +++ b/scripts/finance/index.js @@ -1,25 +1,48 @@ const { - promises: { mkdir } + promises: { mkdir }, } = require('fs'); const { resolve } = require('path'); const writeJSON = require('../utils/readAndWriteJson.js'); -module.exports = async function buildFinanceInfoList({ currentDir, configDir, financeDir, year, jsonDataDir }) { - try { - const expensesPath = resolve(currentDir, configDir, financeDir, year, 'Expenses.yml'); - const expensesLinkPath = resolve(currentDir, configDir, financeDir, year, 'ExpensesLink.yml'); +module.exports = async function buildFinanceInfoList({ + currentDir, + configDir, + financeDir, + year, + jsonDataDir, +}) { + try { + const expensesPath = resolve( + currentDir, + configDir, + financeDir, + year, + 'Expenses.yml', + ); + const expensesLinkPath = resolve( + currentDir, + configDir, + financeDir, + year, + 'ExpensesLink.yml', + ); - // Ensure the directory exists before writing the files - const jsonDirectory = resolve(currentDir, configDir, financeDir, jsonDataDir); - await mkdir(jsonDirectory, { recursive: true }); + // Ensure the directory exists before writing the files + const jsonDirectory = resolve( + currentDir, + configDir, + financeDir, + jsonDataDir, + ); + await mkdir(jsonDirectory, { recursive: true }); - // Write Expenses and ExpensesLink to JSON files - const expensesJsonPath = resolve(jsonDirectory, 'Expenses.json'); - await writeJSON(expensesPath, expensesJsonPath); + // Write Expenses and ExpensesLink to JSON files + const expensesJsonPath = resolve(jsonDirectory, 'Expenses.json'); + await writeJSON(expensesPath, expensesJsonPath); - const expensesLinkJsonPath = resolve(jsonDirectory, 'ExpensesLink.json'); - await writeJSON(expensesLinkPath, expensesLinkJsonPath); - } catch (err) { - throw new Error(err); - } -}; \ No newline at end of file + const expensesLinkJsonPath = resolve(jsonDirectory, 'ExpensesLink.json'); + await writeJSON(expensesLinkPath, expensesLinkJsonPath); + } catch (err) { + throw new Error(err); + } +}; diff --git a/scripts/index.js b/scripts/index.js index 33125fe7533b..0ae68666ce24 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -12,11 +12,11 @@ async function start() { 'blog', 'AsyncAPI Initiative Blog RSS Feed', 'AsyncAPI Initiative Blog', - 'rss.xml' + 'rss.xml', ); await buildCaseStudiesList( 'config/casestudies', - resolve(__dirname, '../config', 'case-studies.json') + resolve(__dirname, '../config', 'case-studies.json'), ); await buildAdoptersList(); const financeDir = resolve('.', 'config', 'finance'); @@ -44,7 +44,7 @@ async function start() { configDir: 'config', financeDir: 'finance', year: latestYear, - jsonDataDir: 'json-data' + jsonDataDir: 'json-data', }); } diff --git a/scripts/markdown/check-markdown.js b/scripts/markdown/check-markdown.js index 8979f7e0b4ab..001a210a2a77 100644 --- a/scripts/markdown/check-markdown.js +++ b/scripts/markdown/check-markdown.js @@ -8,12 +8,12 @@ const path = require('path'); * @returns {boolean} True if the string is a valid URL, false otherwise. */ function isValidURL(str) { - try { - new URL(str); - return true; - } catch (err) { - return false; - } + try { + new URL(str); + return true; + } catch (err) { + return false; + } } /** @@ -23,51 +23,60 @@ function isValidURL(str) { * @returns {string[]|null} An array of validation error messages, or null if no errors. */ function validateBlogs(frontmatter) { - const requiredAttributes = ['title', 'date', 'type', 'tags', 'cover', 'authors']; - const errors = []; - - // Check for required attributes - requiredAttributes.forEach(attr => { - if (!frontmatter.hasOwnProperty(attr)) { - errors.push(`${attr} is missing`); - } - }); - - // Validate date format - if (frontmatter.date && Number.isNaN(Date.parse(frontmatter.date))) { - errors.push(`Invalid date format: ${frontmatter.date}`); + const requiredAttributes = [ + 'title', + 'date', + 'type', + 'tags', + 'cover', + 'authors', + ]; + const errors = []; + + // Check for required attributes + requiredAttributes.forEach((attr) => { + if (!frontmatter.hasOwnProperty(attr)) { + errors.push(`${attr} is missing`); } - - // Validate tags format (must be an array) - if (frontmatter.tags && !Array.isArray(frontmatter.tags)) { - errors.push(`Tags should be an array`); - } - - // Validate cover is a string - if (frontmatter.cover && typeof frontmatter.cover !== 'string') { - errors.push(`Cover must be a string`); - } - - // Validate authors (must be an array with valid attributes) - if (frontmatter.authors) { - if (!Array.isArray(frontmatter.authors)) { - errors.push('Authors should be an array'); - } else { - frontmatter.authors.forEach((author, index) => { - if (!author.name) { - errors.push(`Author at index ${index} is missing a name`); - } - if (author.link && !isValidURL(author.link)) { - errors.push(`Invalid URL for author at index ${index}: ${author.link}`); - } - if (!author.photo) { - errors.push(`Author at index ${index} is missing a photo`); - } - }); + }); + + // Validate date format + if (frontmatter.date && Number.isNaN(Date.parse(frontmatter.date))) { + errors.push(`Invalid date format: ${frontmatter.date}`); + } + + // Validate tags format (must be an array) + if (frontmatter.tags && !Array.isArray(frontmatter.tags)) { + errors.push(`Tags should be an array`); + } + + // Validate cover is a string + if (frontmatter.cover && typeof frontmatter.cover !== 'string') { + errors.push(`Cover must be a string`); + } + + // Validate authors (must be an array with valid attributes) + if (frontmatter.authors) { + if (!Array.isArray(frontmatter.authors)) { + errors.push('Authors should be an array'); + } else { + frontmatter.authors.forEach((author, index) => { + if (!author.name) { + errors.push(`Author at index ${index} is missing a name`); + } + if (author.link && !isValidURL(author.link)) { + errors.push( + `Invalid URL for author at index ${index}: ${author.link}`, + ); } + if (!author.photo) { + errors.push(`Author at index ${index} is missing a photo`); + } + }); } + } - return errors.length ? errors : null; + return errors.length ? errors : null; } /** @@ -77,19 +86,22 @@ function validateBlogs(frontmatter) { * @returns {string[]|null} An array of validation error messages, or null if no errors. */ function validateDocs(frontmatter) { - const errors = []; - - // Check if title exists and is a string - if (!frontmatter.title || typeof frontmatter.title !== 'string') { - errors.push('Title is missing or not a string'); - } - - // Check if weight exists and is a number - if (frontmatter.weight === undefined || typeof frontmatter.weight !== 'number') { - errors.push('Weight is missing or not a number'); - } - - return errors.length ? errors : null; + const errors = []; + + // Check if title exists and is a string + if (!frontmatter.title || typeof frontmatter.title !== 'string') { + errors.push('Title is missing or not a string'); + } + + // Check if weight exists and is a number + if ( + frontmatter.weight === undefined || + typeof frontmatter.weight !== 'number' + ) { + errors.push('Weight is missing or not a number'); + } + + return errors.length ? errors : null; } /** @@ -99,44 +111,44 @@ function validateDocs(frontmatter) { * @param {string} [relativePath=''] - The relative path of the folder for logging purposes. */ function checkMarkdownFiles(folderPath, validateFunction, relativePath = '') { - fs.readdir(folderPath, (err, files) => { + fs.readdir(folderPath, (err, files) => { + if (err) { + console.error('Error reading directory:', err); + return; + } + + files.forEach((file) => { + const filePath = path.join(folderPath, file); + const relativeFilePath = path.join(relativePath, file); + + // Skip the folder 'docs/reference/specification' + if (relativeFilePath.includes('reference/specification')) { + return; + } + + fs.stat(filePath, (err, stats) => { if (err) { - console.error('Error reading directory:', err); - return; + console.error('Error reading file stats:', err); + return; } - files.forEach(file => { - const filePath = path.join(folderPath, file); - const relativeFilePath = path.join(relativePath, file); - - // Skip the folder 'docs/reference/specification' - if (relativeFilePath.includes('reference/specification')) { - return; - } - - fs.stat(filePath, (err, stats) => { - if (err) { - console.error('Error reading file stats:', err); - return; - } - - // Recurse if directory, otherwise validate markdown file - if (stats.isDirectory()) { - checkMarkdownFiles(filePath, validateFunction, relativeFilePath); - } else if (path.extname(file) === '.md') { - const fileContent = fs.readFileSync(filePath, 'utf-8'); - const { data: frontmatter } = matter(fileContent); - - const errors = validateFunction(frontmatter); - if (errors) { - console.log(`Errors in file ${relativeFilePath}:`); - errors.forEach(error => console.log(` - ${error}`)); - process.exitCode = 1; - } - } - }); - }); + // Recurse if directory, otherwise validate markdown file + if (stats.isDirectory()) { + checkMarkdownFiles(filePath, validateFunction, relativeFilePath); + } else if (path.extname(file) === '.md') { + const fileContent = fs.readFileSync(filePath, 'utf-8'); + const { data: frontmatter } = matter(fileContent); + + const errors = validateFunction(frontmatter); + if (errors) { + console.log(`Errors in file ${relativeFilePath}:`); + errors.forEach((error) => console.log(` - ${error}`)); + process.exitCode = 1; + } + } + }); }); + }); } const docsFolderPath = path.resolve(__dirname, '../../markdown/docs'); diff --git a/scripts/tools/categorylist.js b/scripts/tools/categorylist.js index 11fcc3790e9e..15323b1606aa 100644 --- a/scripts/tools/categorylist.js +++ b/scripts/tools/categorylist.js @@ -1,100 +1,119 @@ // Various categories to define the category in which a tool has to be listed const categoryList = [ { - name: "APIs", - tag: "api", - description: "The following is a list of APIs that expose functionality related to AsyncAPI." + name: 'APIs', + tag: 'api', + description: + 'The following is a list of APIs that expose functionality related to AsyncAPI.', }, { - name: "Code-first tools", - tag: "code-first", - description: "The following is a list of tools that generate AsyncAPI documents from your code." + name: 'Code-first tools', + tag: 'code-first', + description: + 'The following is a list of tools that generate AsyncAPI documents from your code.', }, { - name: "Code Generators", - tag: "code-generator", - description: "The following is a list of tools that generate code from an AsyncAPI document; not the other way around." + name: 'Code Generators', + tag: 'code-generator', + description: + 'The following is a list of tools that generate code from an AsyncAPI document; not the other way around.', }, { - name: "Converters", - tag: "converter", - description: "The following is a list of tools that do not yet belong to any specific category but are also useful for the community." + name: 'Converters', + tag: 'converter', + description: + 'The following is a list of tools that do not yet belong to any specific category but are also useful for the community.', }, { - name: "Directories", - tag: "directory", - description: "The following is a list of directories that index public AsyncAPI documents." + name: 'Directories', + tag: 'directory', + description: + 'The following is a list of directories that index public AsyncAPI documents.', }, { - name: "Documentation Generators", - tag: "documentation-generator", - description: "The following is a list of tools that generate human-readable documentation from an AsyncAPI document." + name: 'Documentation Generators', + tag: 'documentation-generator', + description: + 'The following is a list of tools that generate human-readable documentation from an AsyncAPI document.', }, { - name: "Editors", - tag: "editor", - description: "The following is a list of editors or related tools that allow editing of AsyncAPI document." + name: 'Editors', + tag: 'editor', + description: + 'The following is a list of editors or related tools that allow editing of AsyncAPI document.', }, { - name: "UI components", - tag: "ui-component", - description: "The following is a list of UI components to view AsyncAPI documents." + name: 'UI components', + tag: 'ui-component', + description: + 'The following is a list of UI components to view AsyncAPI documents.', }, { - name: "DSL", - tag: "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." + name: 'DSL', + tag: '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.", }, { - name: "Frameworks", - tag: "framework", - description: "The following is a list of API/application frameworks that make use of AsyncAPI." + name: 'Frameworks', + tag: 'framework', + description: + 'The following is a list of API/application frameworks that make use of AsyncAPI.', }, { - name: "GitHub Actions", - tag: "github-action", - description: "The following is a list of GitHub Actions that you can use in your workflows" + name: 'GitHub Actions', + tag: 'github-action', + description: + 'The following is a list of GitHub Actions that you can use in your workflows', }, { - name: "Mocking and Testing", - tag: "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." + name: 'Mocking and Testing', + tag: '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.', }, { - name: "Validators", - tag: "validator", - description: "The following is a list of tools that validate AsyncAPI documents." + name: 'Validators', + tag: 'validator', + description: + 'The following is a list of tools that validate AsyncAPI documents.', }, { - name: "Compare tools", - tag: "compare-tool", - description: "The following is a list of tools that compare AsyncAPI documents." + name: 'Compare tools', + tag: 'compare-tool', + description: + 'The following is a list of tools that compare AsyncAPI documents.', }, { - name: "CLIs", - tag: "cli", - description: "The following is a list of tools that you can work with in terminal or do some CI/CD automation." + name: 'CLIs', + tag: 'cli', + description: + 'The following is a list of tools that you can work with in terminal or do some CI/CD automation.', }, { - name: "Bundlers", - tag: "bundler", - description: "The following is a list of tools that you can work with to bundle AsyncAPI documents." + name: 'Bundlers', + tag: 'bundler', + description: + 'The following is a list of tools that you can work with to bundle AsyncAPI documents.', }, { - name: "IDE Extensions", - tag: "ide-extension", - description: "The following is a list of extensions for different IDEs like VSCode, IntelliJ IDEA and others" + name: 'IDE Extensions', + tag: 'ide-extension', + description: + 'The following is a list of extensions for different IDEs like VSCode, IntelliJ IDEA and others', }, { - name: "AsyncAPI Generator Templates", - tag: "generator-template", - 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." + name: 'AsyncAPI Generator Templates', + tag: 'generator-template', + 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.', }, { - name: "Others", - tag: "other", - description: "The following is a list of tools that comes under Other category." - } -] + name: 'Others', + tag: 'other', + description: + 'The following is a list of tools that comes under Other category.', + }, +]; -module.exports = {categoryList} +module.exports = { categoryList }; diff --git a/scripts/tools/combine-tools.js b/scripts/tools/combine-tools.js index 602262428fa1..34980f1abd61 100644 --- a/scripts/tools/combine-tools.js +++ b/scripts/tools/combine-tools.js @@ -1,142 +1,160 @@ -const { languagesColor, technologiesColor } = require("./tags-color") -const { categoryList } = require("./categorylist.js") -const { createToolObject } = require("./tools-object") -const fs = require('fs') -const schema = require("./tools-schema.json"); -const Ajv = require("ajv") -const addFormats = require("ajv-formats") -const Fuse = require("fuse.js"); -const ajv = new Ajv() -addFormats(ajv, ["uri"]) -const validate = ajv.compile(schema) +const { languagesColor, technologiesColor } = require('./tags-color'); +const { categoryList } = require('./categorylist.js'); +const { createToolObject } = require('./tools-object'); +const fs = require('fs'); +const schema = require('./tools-schema.json'); +const Ajv = require('ajv'); +const addFormats = require('ajv-formats'); +const Fuse = require('fuse.js'); +const ajv = new Ajv(); +addFormats(ajv, ['uri']); +const validate = ajv.compile(schema); let finalTools = {}; for (var category of categoryList) { - finalTools[category.name] = { - description: category.description, - toolsList: [] - }; + finalTools[category.name] = { + description: category.description, + toolsList: [], + }; } // Config options set for the Fuse object const options = { - includeScore: true, - shouldSort: true, - threshold: 0.39, - keys: ['name', 'color', 'borderColor'] -} + includeScore: true, + shouldSort: true, + threshold: 0.39, + keys: ['name', 'color', 'borderColor'], +}; -// Two seperate lists and Fuse objects initialised to search languages and technologies tags +// Two seperate lists and Fuse objects initialised to search languages and technologies tags // from specified list of same. -let languageList = [...languagesColor], technologyList = [...technologiesColor]; -let languageFuse = new Fuse(languageList, options), technologyFuse = new Fuse(technologyList, options) +let languageList = [...languagesColor], + technologyList = [...technologiesColor]; +let languageFuse = new Fuse(languageList, options), + technologyFuse = new Fuse(technologyList, options); -// takes individual tool object and inserts borderColor and backgroundColor of the tags of +// takes individual tool object and inserts borderColor and backgroundColor of the tags of // languages and technologies, for Tool Card in website. const getFinalTool = async (toolObject) => { - let finalObject = toolObject; + let finalObject = toolObject; - //there might be a tool without language - if (toolObject.filters.language) { - let languageArray = [] - if (typeof toolObject.filters.language === 'string') { - const languageSearch = await languageFuse.search(toolObject.filters.language) - if (languageSearch.length) { - languageArray.push(languageSearch[0].item); - } else { - // adds a new language object in the Fuse list as well as in tool object - // so that it isn't missed out in the UI. - let languageObject = { - name: toolObject.filters.language, - color: 'bg-[#57f281]', - borderColor: 'border-[#37f069]' - } - languageList.push(languageObject); - languageArray.push(languageObject) - languageFuse = new Fuse(languageList, options) - } + //there might be a tool without language + if (toolObject.filters.language) { + let languageArray = []; + if (typeof toolObject.filters.language === 'string') { + const languageSearch = await languageFuse.search( + toolObject.filters.language, + ); + if (languageSearch.length) { + languageArray.push(languageSearch[0].item); + } else { + // adds a new language object in the Fuse list as well as in tool object + // so that it isn't missed out in the UI. + let languageObject = { + name: toolObject.filters.language, + color: 'bg-[#57f281]', + borderColor: 'border-[#37f069]', + }; + languageList.push(languageObject); + languageArray.push(languageObject); + languageFuse = new Fuse(languageList, options); + } + } else { + for (const language of toolObject?.filters?.language) { + const languageSearch = await languageFuse.search(language); + if (languageSearch.length > 0) { + languageArray.push(languageSearch[0].item); } else { - for (const language of toolObject?.filters?.language) { - const languageSearch = await languageFuse.search(language) - if (languageSearch.length > 0) { - languageArray.push(languageSearch[0].item); - } - else { - // adds a new language object in the Fuse list as well as in tool object - // so that it isn't missed out in the UI. - let languageObject = { - name: language, - color: 'bg-[#57f281]', - borderColor: 'border-[#37f069]' - } - languageList.push(languageObject); - languageArray.push(languageObject) - languageFuse = new Fuse(languageList, options) - } - } + // adds a new language object in the Fuse list as well as in tool object + // so that it isn't missed out in the UI. + let languageObject = { + name: language, + color: 'bg-[#57f281]', + borderColor: 'border-[#37f069]', + }; + languageList.push(languageObject); + languageArray.push(languageObject); + languageFuse = new Fuse(languageList, options); } - finalObject.filters.language = languageArray + } } - let technologyArray = []; - if (toolObject.filters.technology) { - for (const technology of toolObject?.filters?.technology) { - const technologySearch = await technologyFuse.search(technology) - if (technologySearch.length > 0) { - technologyArray.push(technologySearch[0].item); - } - else { - // adds a new technology object in the Fuse list as well as in tool object - // so that it isn't missed out in the UI. - let technologyObject = { - name: technology, - color: 'bg-[#61d0f2]', - borderColor: 'border-[#40ccf7]' - } - technologyList.push(technologyObject); - technologyArray.push(technologyObject); - technologyFuse = new Fuse(technologyList, options) - } - } + finalObject.filters.language = languageArray; + } + let technologyArray = []; + if (toolObject.filters.technology) { + for (const technology of toolObject?.filters?.technology) { + const technologySearch = await technologyFuse.search(technology); + if (technologySearch.length > 0) { + technologyArray.push(technologySearch[0].item); + } else { + // adds a new technology object in the Fuse list as well as in tool object + // so that it isn't missed out in the UI. + let technologyObject = { + name: technology, + color: 'bg-[#61d0f2]', + borderColor: 'border-[#40ccf7]', + }; + technologyList.push(technologyObject); + technologyArray.push(technologyObject); + technologyFuse = new Fuse(technologyList, options); + } } - finalObject.filters.technology = technologyArray; - return finalObject; -} - + } + finalObject.filters.technology = technologyArray; + return finalObject; +}; -// Combine the automated tools and manual tools list into single JSON object file, and +// 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, toolsPath, tagsPath) => { - for (const key in automatedTools) { - let finalToolsList = []; - if (automatedTools[key].toolsList.length) { - for (const tool of automatedTools[key].toolsList) { - finalToolsList.push(await getFinalTool(tool)) - } - } - if (manualTools[key] && manualTools[key].toolsList.length) { - for (const tool of manualTools[key].toolsList) { - let isAsyncAPIrepo; - const isValid = await validate(tool) - if (isValid) { - if (tool?.links?.repoUrl) { - const url = new URL(tool.links.repoUrl) - isAsyncAPIrepo = url.href.startsWith("https://github.com/asyncapi/") - } else isAsyncAPIrepo = false - let toolObject = await createToolObject(tool, "", "", isAsyncAPIrepo) - finalToolsList.push(await getFinalTool(toolObject)) - } else { - console.error('Script is not failing, it is just dropping errors for further investigation'); - console.error(`Invalid ${tool.title} .asyncapi-tool file.`); - console.error(`Located in manual-tools.json file`); - console.error('Validation errors:', JSON.stringify(validate.errors, null, 2)); - } - } +const combineTools = async ( + automatedTools, + manualTools, + toolsPath, + tagsPath, +) => { + for (const key in automatedTools) { + let finalToolsList = []; + if (automatedTools[key].toolsList.length) { + for (const tool of automatedTools[key].toolsList) { + finalToolsList.push(await getFinalTool(tool)); + } + } + if (manualTools[key] && manualTools[key].toolsList.length) { + for (const tool of manualTools[key].toolsList) { + let isAsyncAPIrepo; + const isValid = await validate(tool); + if (isValid) { + if (tool?.links?.repoUrl) { + const url = new URL(tool.links.repoUrl); + isAsyncAPIrepo = url.href.startsWith( + 'https://github.com/asyncapi/', + ); + } else isAsyncAPIrepo = false; + let toolObject = await createToolObject(tool, '', '', isAsyncAPIrepo); + finalToolsList.push(await getFinalTool(toolObject)); + } else { + console.error( + 'Script is not failing, it is just dropping errors for further investigation', + ); + console.error(`Invalid ${tool.title} .asyncapi-tool file.`); + console.error(`Located in manual-tools.json file`); + console.error( + 'Validation errors:', + JSON.stringify(validate.errors, null, 2), + ); } - finalToolsList.sort((tool, anotherTool) => tool.title.localeCompare(anotherTool.title)); - finalTools[key].toolsList = finalToolsList + } } - fs.writeFileSync(toolsPath,JSON.stringify(finalTools)); - fs.writeFileSync(tagsPath,JSON.stringify({ languages: languageList, technologies: technologyList }),) -} + finalToolsList.sort((tool, anotherTool) => + tool.title.localeCompare(anotherTool.title), + ); + finalTools[key].toolsList = finalToolsList; + } + fs.writeFileSync(toolsPath, JSON.stringify(finalTools)); + fs.writeFileSync( + tagsPath, + JSON.stringify({ languages: languageList, technologies: technologyList }), + ); +}; -module.exports = { combineTools } \ No newline at end of file +module.exports = { combineTools }; diff --git a/scripts/tools/extract-tools-github.js b/scripts/tools/extract-tools-github.js index 55e96124b752..567a8077be4b 100644 --- a/scripts/tools/extract-tools-github.js +++ b/scripts/tools/extract-tools-github.js @@ -1,5 +1,5 @@ const axios = require('axios'); -require('dotenv').config() +require('dotenv').config(); const getData = async () => { try { @@ -10,7 +10,7 @@ const getData = async () => { accept: 'application/vnd.github.text-match+json', authorization: `token ${process.env.GITHUB_TOKEN}`, }, - } + }, ); return result.data; @@ -19,4 +19,4 @@ const getData = async () => { } }; -module.exports = { getData }; \ No newline at end of file +module.exports = { getData }; diff --git a/scripts/tools/tags-color.js b/scripts/tools/tags-color.js index 9a18ca2058d5..5897fcab5837 100644 --- a/scripts/tools/tags-color.js +++ b/scripts/tools/tags-color.js @@ -1,178 +1,178 @@ // Language and Technology tags along with their colors in UI are defined here. const languagesColor = [ - { - name: "Go/Golang", - color: "bg-[#8ECFDF]", - borderColor: "border-[#00AFD9]" - }, - { - name: "Java", - color: "bg-[#ECA2A4]", - borderColor: "border-[#EC2125]" - }, - { - name: "JavaScript", - color: "bg-[#F2F1C7]", - borderColor: "border-[#BFBE86]" - }, - { - name: "HTML", - color: "bg-[#E2A291]", - borderColor: "border-[#E44D26]" - }, - { - name: "C/C++", - color: "bg-[#93CDEF]", - borderColor: "border-[#0080CC]" - }, - { - name: "C#", - color: "bg-[#E3AFE0]", - borderColor: "border-[#9B4F96]" - }, - { - name: "Python", - color: "bg-[#A8D0EF]", - borderColor: "border-[#3878AB]" - }, - { - name: "TypeScript", - color: "bg-[#7DBCFE]", - borderColor: "border-[#2C78C7]" - }, - { - name: "Kotlin", - color: "bg-[#B1ACDF]", - borderColor: "border-[#756BD9]" - }, - { - name: "Scala", - color: "bg-[#FFA299]", - borderColor: "border-[#DF301F]" - }, - { - name: "Markdown", - color: "bg-[#BABEBF]", - borderColor: "border-[#445B64]" - }, - { - name: "YAML", - color: "bg-[#FFB764]", - borderColor: "border-[#F1901F]" - }, - { - name: "R", - color: "bg-[#84B5ED]", - borderColor: "border-[#246BBE]" - }, - { - name: "Ruby", - color: "bg-[#FF8289]", - borderColor: "border-[#FF000F]" - }, - { - name: "Rust", - color: "bg-[#FFB8AA]", - borderColor: "border-[#E43716]" - }, - { - name: "Shell", - color: "bg-[#87D4FF]", - borderColor: "border-[#389ED7]" - }, - { - name: "Groovy", - color: "bg-[#B6D5E5]", - borderColor: "border-[#609DBC]" - } -] + { + name: 'Go/Golang', + color: 'bg-[#8ECFDF]', + borderColor: 'border-[#00AFD9]', + }, + { + name: 'Java', + color: 'bg-[#ECA2A4]', + borderColor: 'border-[#EC2125]', + }, + { + name: 'JavaScript', + color: 'bg-[#F2F1C7]', + borderColor: 'border-[#BFBE86]', + }, + { + name: 'HTML', + color: 'bg-[#E2A291]', + borderColor: 'border-[#E44D26]', + }, + { + name: 'C/C++', + color: 'bg-[#93CDEF]', + borderColor: 'border-[#0080CC]', + }, + { + name: 'C#', + color: 'bg-[#E3AFE0]', + borderColor: 'border-[#9B4F96]', + }, + { + name: 'Python', + color: 'bg-[#A8D0EF]', + borderColor: 'border-[#3878AB]', + }, + { + name: 'TypeScript', + color: 'bg-[#7DBCFE]', + borderColor: 'border-[#2C78C7]', + }, + { + name: 'Kotlin', + color: 'bg-[#B1ACDF]', + borderColor: 'border-[#756BD9]', + }, + { + name: 'Scala', + color: 'bg-[#FFA299]', + borderColor: 'border-[#DF301F]', + }, + { + name: 'Markdown', + color: 'bg-[#BABEBF]', + borderColor: 'border-[#445B64]', + }, + { + name: 'YAML', + color: 'bg-[#FFB764]', + borderColor: 'border-[#F1901F]', + }, + { + name: 'R', + color: 'bg-[#84B5ED]', + borderColor: 'border-[#246BBE]', + }, + { + name: 'Ruby', + color: 'bg-[#FF8289]', + borderColor: 'border-[#FF000F]', + }, + { + name: 'Rust', + color: 'bg-[#FFB8AA]', + borderColor: 'border-[#E43716]', + }, + { + name: 'Shell', + color: 'bg-[#87D4FF]', + borderColor: 'border-[#389ED7]', + }, + { + name: 'Groovy', + color: 'bg-[#B6D5E5]', + borderColor: 'border-[#609DBC]', + }, +]; const technologiesColor = [ - { - name: "Node.js", - color: "bg-[#BDFF67]", - borderColor: "border-[#84CE24]" - }, - { - name: "Hermes", - color: "bg-[#8AEEBD]", - borderColor: "border-[#2AB672]" - }, - { - name: "React JS", - color: "bg-[#9FECFA]", - borderColor: "border-[#08D8FE]" - }, - { - name: ".NET", - color: "bg-[#A184FF]", - borderColor: "border-[#5026D4]" - }, - { - name: "ASP.NET", - color: "bg-[#71C2FB]", - borderColor: "border-[#1577BC]" - }, - { - name: "Springboot", - color: "bg-[#98E279]", - borderColor: "border-[#68BC44]" - }, - { - name: "AWS", - color: "bg-[#FF9F59]", - borderColor: "border-[#EF6703]" - }, - { - name: "Docker", - color: "bg-[#B8E0FF]", - borderColor: "border-[#2596ED]" - }, - { - name: "Node-RED", - color: "bg-[#FF7474]", - borderColor: "border-[#8F0101]" - }, - { - name: "Maven", - color: "bg-[#FF6B80]", - borderColor: "border-[#CA1A33]" - }, - { - name: "Saas", - color: "bg-[#6AB8EC]", - borderColor: "border-[#2275AD]" - }, - { - name: "Kubernetes-native", - color: "bg-[#D7C7F2]", - borderColor: "border-[#A387D2]" - }, - { - name: "Scala", - color: "bg-[#D7C7F2]", - borderColor: "border-[#A387D2]" - }, - { - name: "Azure", - color: "bg-[#4B93FF]", - borderColor: "border-[#015ADF]" - }, - { - name: "Jenkins", - color: "bg-[#D7C7F2]", - borderColor: "border-[#A387D2]" - }, - { - name: "Flask", - color: "bg-[#D7C7F2]", - borderColor: "border-[#A387D2]" - }, - { - name: "Nest Js", - color: "bg-[#E1224E]", - borderColor: "border-[#B9012b]" - } -] + { + name: 'Node.js', + color: 'bg-[#BDFF67]', + borderColor: 'border-[#84CE24]', + }, + { + name: 'Hermes', + color: 'bg-[#8AEEBD]', + borderColor: 'border-[#2AB672]', + }, + { + name: 'React JS', + color: 'bg-[#9FECFA]', + borderColor: 'border-[#08D8FE]', + }, + { + name: '.NET', + color: 'bg-[#A184FF]', + borderColor: 'border-[#5026D4]', + }, + { + name: 'ASP.NET', + color: 'bg-[#71C2FB]', + borderColor: 'border-[#1577BC]', + }, + { + name: 'Springboot', + color: 'bg-[#98E279]', + borderColor: 'border-[#68BC44]', + }, + { + name: 'AWS', + color: 'bg-[#FF9F59]', + borderColor: 'border-[#EF6703]', + }, + { + name: 'Docker', + color: 'bg-[#B8E0FF]', + borderColor: 'border-[#2596ED]', + }, + { + name: 'Node-RED', + color: 'bg-[#FF7474]', + borderColor: 'border-[#8F0101]', + }, + { + name: 'Maven', + color: 'bg-[#FF6B80]', + borderColor: 'border-[#CA1A33]', + }, + { + name: 'Saas', + color: 'bg-[#6AB8EC]', + borderColor: 'border-[#2275AD]', + }, + { + name: 'Kubernetes-native', + color: 'bg-[#D7C7F2]', + borderColor: 'border-[#A387D2]', + }, + { + name: 'Scala', + color: 'bg-[#D7C7F2]', + borderColor: 'border-[#A387D2]', + }, + { + name: 'Azure', + color: 'bg-[#4B93FF]', + borderColor: 'border-[#015ADF]', + }, + { + name: 'Jenkins', + color: 'bg-[#D7C7F2]', + borderColor: 'border-[#A387D2]', + }, + { + name: 'Flask', + color: 'bg-[#D7C7F2]', + borderColor: 'border-[#A387D2]', + }, + { + name: 'Nest Js', + color: 'bg-[#E1224E]', + borderColor: 'border-[#B9012b]', + }, +]; -module.exports = {languagesColor, technologiesColor} \ No newline at end of file +module.exports = { languagesColor, technologiesColor }; diff --git a/scripts/tools/tools-object.js b/scripts/tools/tools-object.js index e5a30334f7d3..9ef57e5cab31 100644 --- a/scripts/tools/tools-object.js +++ b/scripts/tools/tools-object.js @@ -1,50 +1,58 @@ -const schema = require("./tools-schema.json"); -const axios = require('axios') -const Ajv = require("ajv") -const addFormats = require("ajv-formats") -const Fuse = require("fuse.js") -const { categoryList } = require("./categorylist") -const ajv = new Ajv() -addFormats(ajv, ["uri"]) -const validate = ajv.compile(schema) +const schema = require('./tools-schema.json'); +const axios = require('axios'); +const Ajv = require('ajv'); +const addFormats = require('ajv-formats'); +const Fuse = require('fuse.js'); +const { categoryList } = require('./categorylist'); +const ajv = new Ajv(); +addFormats(ajv, ['uri']); +const validate = ajv.compile(schema); const { convertToJson } = require('../utils'); - // Config options set for the Fuse object const options = { includeScore: true, shouldSort: true, threshold: 0.4, - keys: ["tag"] -} + keys: ['tag'], +}; -const fuse = new Fuse(categoryList, options) +const fuse = new Fuse(categoryList, options); -// using the contents of each toolFile (extracted from Github), along with Github URL -// (repositoryUrl) of the tool, it's repository description (repoDescription) and -// isAsyncAPIrepo boolean variable to define whether the tool repository is under -// AsyncAPI organization or not, to create a JSON tool object as required in the frontend +// using the contents of each toolFile (extracted from Github), along with Github URL +// (repositoryUrl) of the tool, it's repository description (repoDescription) and +// isAsyncAPIrepo boolean variable to define whether the tool repository is under +// AsyncAPI organization or not, to create a JSON tool object as required in the frontend // side to show ToolCard. -const createToolObject = async (toolFile, repositoryUrl='', repoDescription='', isAsyncAPIrepo='') => { +const createToolObject = async ( + toolFile, + repositoryUrl = '', + repoDescription = '', + isAsyncAPIrepo = '', +) => { let resultantObject = { title: toolFile.title, description: toolFile?.description ? toolFile.description : repoDescription, links: { ...toolFile.links, - repoUrl: toolFile?.links?.repoUrl ? toolFile.links.repoUrl : repositoryUrl + repoUrl: toolFile?.links?.repoUrl + ? toolFile.links.repoUrl + : repositoryUrl, }, filters: { ...toolFile.filters, - hasCommercial: toolFile?.filters?.hasCommercial ? toolFile.filters.hasCommercial : false, - isAsyncAPIOwner: isAsyncAPIrepo - } + hasCommercial: toolFile?.filters?.hasCommercial + ? toolFile.filters.hasCommercial + : false, + isAsyncAPIOwner: isAsyncAPIrepo, + }, }; return resultantObject; }; -// Each result obtained from the Github API call will be tested and verified +// Each result obtained from the Github API call will be tested and verified // using the defined JSON schema, categorising each tool inside their defined categories -// and creating a JSON tool object in which all the tools are listed in defined +// and creating a JSON tool object in which all the tools are listed in defined // categories order, which is then updated in `automated-tools.json` file. async function convertTools(data) { let finalToolsObject = {}; @@ -54,7 +62,7 @@ async function convertTools(data) { for (var index in categoryList) { finalToolsObject[categoryList[index].name] = { description: categoryList[index].description, - toolsList: [] + toolsList: [], }; } @@ -64,50 +72,70 @@ async function convertTools(data) { // extracting the reference id of the repository which will be used to extract the path of the .asyncapi-tool file in the Tools repository // ex: for a url = "https://api.github.com/repositories/351453552/contents/.asyncapi-tool?ref=61855e7365a881e98c2fe667a658a0005753d873" // the text (id) present after '=' gives us a reference id for the repo - let reference_id = tool.url.split("=")[1]; + let reference_id = tool.url.split('=')[1]; let download_url = `https://raw.githubusercontent.com/${tool.repository.full_name}/${reference_id}/${tool.path}`; const { data: toolFileContent } = await axios.get(download_url); //some stuff can be YAML - const jsonToolFileContent = await convertToJson(toolFileContent) + const jsonToolFileContent = await convertToJson(toolFileContent); //validating against JSON Schema for tools file - const isValid = await validate(jsonToolFileContent) + const isValid = await validate(jsonToolFileContent); if (isValid) { let repositoryUrl = tool.repository.html_url; let repoDescription = tool.repository.description; - let isAsyncAPIrepo = tool.repository.owner.login === "asyncapi"; - let toolObject = await createToolObject(jsonToolFileContent, repositoryUrl, repoDescription, isAsyncAPIrepo); + let isAsyncAPIrepo = tool.repository.owner.login === 'asyncapi'; + let toolObject = await createToolObject( + jsonToolFileContent, + repositoryUrl, + repoDescription, + isAsyncAPIrepo, + ); // Tool Object is appended to each category array according to Fuse search for categories inside Tool Object jsonToolFileContent.filters.categories.forEach(async (category) => { const categorySearch = await fuse.search(category); if (categorySearch.length) { - let searchedCategoryName = categorySearch[0].item.name - if (!finalToolsObject[searchedCategoryName].toolsList.find((element => element === toolObject))) - finalToolsObject[searchedCategoryName].toolsList.push(toolObject); + let searchedCategoryName = categorySearch[0].item.name; + if ( + !finalToolsObject[searchedCategoryName].toolsList.find( + (element) => element === toolObject, + ) + ) + finalToolsObject[searchedCategoryName].toolsList.push( + toolObject, + ); } else { // if Tool object has a category, not defined in our categorylist, then this provides a `other` category to the tool. - if (!finalToolsObject['Others'].toolsList.find((element => element === toolObject))) + if ( + !finalToolsObject['Others'].toolsList.find( + (element) => element === toolObject, + ) + ) finalToolsObject['Others'].toolsList.push(toolObject); } }); } else { - console.error('Script is not failing, it is just dropping errors for further investigation'); + console.error( + 'Script is not failing, it is just dropping errors for further investigation', + ); console.error('Invalid .asyncapi-tool file.'); console.error(`Located in: ${tool.html_url}`); - console.error('Validation errors:', JSON.stringify(validate.errors, null, 2)); + console.error( + 'Validation errors:', + JSON.stringify(validate.errors, null, 2), + ); } } } catch (err) { - console.error(err) + console.error(err); throw err; } } return finalToolsObject; } -module.exports = {convertTools, createToolObject} \ No newline at end of file +module.exports = { convertTools, createToolObject }; diff --git a/scripts/tools/tools-schema.json b/scripts/tools/tools-schema.json index e11968a1b2e1..74bcb3d783b4 100644 --- a/scripts/tools/tools-schema.json +++ b/scripts/tools/tools-schema.json @@ -1,220 +1,209 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "JSON Schema for AsyncAPI tool discovery file.", - "type": "object", - "additionalProperties": false, - "required": [ - "title", - "filters" - ], - "properties": { - "title": { - "type": "string", - "description": "Human-readable name of the tool that will be visible to people in the list of tools.", - "examples": [ - "AsyncAPI Generator", - "Cupid" - ] + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "JSON Schema for AsyncAPI tool discovery file.", + "type": "object", + "additionalProperties": false, + "required": ["title", "filters"], + "properties": { + "title": { + "type": "string", + "description": "Human-readable name of the tool that will be visible to people in the list of tools.", + "examples": ["AsyncAPI Generator", "Cupid"] + }, + "description": { + "type": "string", + "description": "By default scripts read description of repository there project is stored. You can override this behaviour by providing custom description." + }, + "links": { + "type": "object", + "additionalProperties": false, + "properties": { + "websiteUrl": { + "type": "string", + "description": "You can provide URL to the website where your project hosts some demo or project landing page.", + "format": "uri" }, - "description": { - "type": "string", - "description": "By default scripts read description of repository there project is stored. You can override this behaviour by providing custom description." + "docsUrl": { + "type": "string", + "description": "You can provide URL to project documentation in case you have more than just a readme file.", + "format": "uri" }, - "links": { - "type": "object", - "additionalProperties": false, - "properties": { - "websiteUrl": { - "type": "string", - "description": "You can provide URL to the website where your project hosts some demo or project landing page.", - "format": "uri" - }, - "docsUrl": { - "type": "string", - "description": "You can provide URL to project documentation in case you have more than just a readme file.", - "format": "uri" + "repoUrl": { + "type": "string", + "description": "You can provide URL to project codebase in case you have more than one tool present inside single repository.", + "format": "uri" + } + } + }, + "filters": { + "type": "object", + "additionalProperties": false, + "required": ["categories"], + "properties": { + "language": { + "description": "The language referred to is the runtime language selected by the user, not the generator or library language. For example, the Generator written in JavaScript generates Python code from the JavaScript template and the result of generation is a Python app, so the language for Generator is specified as Python. But for the Bundler library, users need to know if it can be integrated into their TypeScript codebase, so its language is specified as TypeScript. If some language in the schema's enum is omitted, it can be added through a pull request to the AsyncAPI website repository.", + "anyOf": [ + { + "type": "string", + "anyOf": [ + { + "type": "string", + "enum": [ + "Go", + "Java", + "JavaScript", + "HTML", + "C/C++", + "C#", + "Python", + "TypeScript", + "Kotlin", + "Scala", + "Markdown", + "YAML", + "R", + "Ruby", + "Rust", + "Shell", + "Groovy" + ] }, - "repoUrl": { - "type": "string", - "description": "You can provide URL to project codebase in case you have more than one tool present inside single repository.", - "format": "uri" + { + "type": "string" } - } - }, - "filters": { - "type": "object", - "additionalProperties": false, - "required": [ - "categories" - ], - "properties": { - "language": { - "description": "The language referred to is the runtime language selected by the user, not the generator or library language. For example, the Generator written in JavaScript generates Python code from the JavaScript template and the result of generation is a Python app, so the language for Generator is specified as Python. But for the Bundler library, users need to know if it can be integrated into their TypeScript codebase, so its language is specified as TypeScript. If some language in the schema's enum is omitted, it can be added through a pull request to the AsyncAPI website repository.", - "anyOf": [ - { - "type": "string", - "anyOf": [ - { - "type": "string", - "enum": [ - "Go", - "Java", - "JavaScript", - "HTML", - "C/C++", - "C#", - "Python", - "TypeScript", - "Kotlin", - "Scala", - "Markdown", - "YAML", - "R", - "Ruby", - "Rust", - "Shell", - "Groovy" - ] - }, - { - "type": "string" - } - ] - }, - { - "type": "array", - "items": { - "type": "string", - "anyOf": [ - { - "type": "string", - "enum": [ - "Go", - "Java", - "JavaScript", - "HTML", - "C/C++", - "C#", - "Python", - "TypeScript", - "Kotlin", - "Scala", - "Markdown", - "YAML", - "R", - "Ruby", - "Rust", - "Shell", - "Groovy" - ] - }, - { - "type": "string" - } - ] - } - } - ] - }, - "technology": { - "type": "array", - "description": "Provide a list of different technologies used in the tool. Put details useful for tool user and tool contributor.", - "items": { - "type": "string", - "anyOf": [ - { - "type": "string", - "enum": [ - "Node js", - "Hermes", - "React JS", - ".NET", - "ASP.NET", - "Springboot", - "AWS", - "Docker", - "Node-red", - "Maven", - "Saas", - "Kubernetes-native", - "Scala", - "Azure", - "Jenkins", - "Flask" - ] - }, - { - "type": "string" - } - ] - }, - "examples": [ - "Express.js", - "Kafka" - ] - }, - "categories": { - "type": "array", - "description": "Categories are used to group tools by different use case, like documentation or code generation. If have a list of fixed categories. If you use different one that your tool lands under \"other\" category. Feel free to add your category through a pull request to AsyncAPI website repository.", - "items": { - "type": "string", - "anyOf": [ - { - "type": "string", - "enum": [ - "api", - "code-first", - "code-generator", - "converter", - "directory", - "documentation-generator", - "editor", - "ui-component", - "dsl", - "framework", - "github-action", - "mocking-and-testing", - "validator", - "compare-tool", - "other", - "cli", - "bundler", - "ide-extension" - ] - }, - { - "type": "string" - } - ] - }, - "minItems": 1, - "examples": [ - "api", - "code-first", - "code-generator", - "converter", - "directory", - "documentation-generator", - "editor", - "ui-component", - "dsl", - "framework", - "github-action", - "mocking-and-testing", - "validator", - "compare-tool", - "other", - "cli", - "bundler", - "ide-extension" + ] + }, + { + "type": "array", + "items": { + "type": "string", + "anyOf": [ + { + "type": "string", + "enum": [ + "Go", + "Java", + "JavaScript", + "HTML", + "C/C++", + "C#", + "Python", + "TypeScript", + "Kotlin", + "Scala", + "Markdown", + "YAML", + "R", + "Ruby", + "Rust", + "Shell", + "Groovy" ] - }, - "hasCommercial": { - "type": "boolean", - "description": "Indicate if your tool is open source or commercial offering, like SAAS for example", - "default": false - } + }, + { + "type": "string" + } + ] + } } + ] + }, + "technology": { + "type": "array", + "description": "Provide a list of different technologies used in the tool. Put details useful for tool user and tool contributor.", + "items": { + "type": "string", + "anyOf": [ + { + "type": "string", + "enum": [ + "Node js", + "Hermes", + "React JS", + ".NET", + "ASP.NET", + "Springboot", + "AWS", + "Docker", + "Node-red", + "Maven", + "Saas", + "Kubernetes-native", + "Scala", + "Azure", + "Jenkins", + "Flask" + ] + }, + { + "type": "string" + } + ] + }, + "examples": ["Express.js", "Kafka"] + }, + "categories": { + "type": "array", + "description": "Categories are used to group tools by different use case, like documentation or code generation. If have a list of fixed categories. If you use different one that your tool lands under \"other\" category. Feel free to add your category through a pull request to AsyncAPI website repository.", + "items": { + "type": "string", + "anyOf": [ + { + "type": "string", + "enum": [ + "api", + "code-first", + "code-generator", + "converter", + "directory", + "documentation-generator", + "editor", + "ui-component", + "dsl", + "framework", + "github-action", + "mocking-and-testing", + "validator", + "compare-tool", + "other", + "cli", + "bundler", + "ide-extension" + ] + }, + { + "type": "string" + } + ] + }, + "minItems": 1, + "examples": [ + "api", + "code-first", + "code-generator", + "converter", + "directory", + "documentation-generator", + "editor", + "ui-component", + "dsl", + "framework", + "github-action", + "mocking-and-testing", + "validator", + "compare-tool", + "other", + "cli", + "bundler", + "ide-extension" + ] + }, + "hasCommercial": { + "type": "boolean", + "description": "Indicate if your tool is open source or commercial offering, like SAAS for example", + "default": false } + } } -} \ No newline at end of file + } +} diff --git a/scripts/utils.js b/scripts/utils.js index c740ae91eaef..66d01b75afc7 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -1,26 +1,28 @@ const yaml = require('yaml'); function convertToJson(contentYAMLorJSON) { - // Axios handles conversion to JSON by default, if data returned from the server allows it - // So if returned content is not a string (not YAML), we just return JSON back - if (typeof contentYAMLorJSON !== "string") { - return contentYAMLorJSON; - } + // Axios handles conversion to JSON by default, if data returned from the server allows it + // So if returned content is not a string (not YAML), we just return JSON back + if (typeof contentYAMLorJSON !== 'string') { + return contentYAMLorJSON; + } - // Check if the content is valid JSON before attempting to parse as YAML + // Check if the content is valid JSON before attempting to parse as YAML + try { + const jsonContent = JSON.parse(contentYAMLorJSON); + return jsonContent; + } catch (jsonError) { + // If it's not valid JSON, try parsing it as YAML try { - const jsonContent = JSON.parse(contentYAMLorJSON); - return jsonContent; - } catch (jsonError) { - // If it's not valid JSON, try parsing it as YAML - try { - const yamlContent = yaml.parse(contentYAMLorJSON); - return yamlContent; - } catch (yamlError) { - // If parsing as YAML also fails, throw an error - throw new Error(`Invalid content format:\nJSON Parse Error: ${jsonError}\nYAML Parse Error: ${yamlError}`); - } + const yamlContent = yaml.parse(contentYAMLorJSON); + return yamlContent; + } catch (yamlError) { + // If parsing as YAML also fails, throw an error + throw new Error( + `Invalid content format:\nJSON Parse Error: ${jsonError}\nYAML Parse Error: ${yamlError}`, + ); } + } } module.exports = { convertToJson }; diff --git a/scripts/utils/readAndWriteJson.js b/scripts/utils/readAndWriteJson.js index 3c7f05d2308b..d1ed2dd43a12 100644 --- a/scripts/utils/readAndWriteJson.js +++ b/scripts/utils/readAndWriteJson.js @@ -1,28 +1,30 @@ -const { promises: { readFile, writeFile } } = require('fs'); -const { convertToJson } = require("../utils"); +const { + promises: { readFile, writeFile }, +} = require('fs'); +const { convertToJson } = require('../utils'); module.exports = async function writeJSON(readPath, writePath) { - let readContent; - let jsonContent; + let readContent; + let jsonContent; - // Attempt to read the file - try { - readContent = await readFile(readPath, 'utf-8'); - } catch (err) { - throw new Error(`Error while reading file\nError: ${err}`); - } + // Attempt to read the file + try { + readContent = await readFile(readPath, 'utf-8'); + } catch (err) { + throw new Error(`Error while reading file\nError: ${err}`); + } - // Attempt to convert content to JSON - try { - jsonContent = convertToJson(readContent); - } catch (err) { - throw new Error(`Error while conversion\nError: ${err}`); - } + // Attempt to convert content to JSON + try { + jsonContent = convertToJson(readContent); + } catch (err) { + throw new Error(`Error while conversion\nError: ${err}`); + } - // Attempt to write the JSON content to file - try { - await writeFile(writePath, JSON.stringify(jsonContent)); - } catch (err) { - throw new Error(`Error while writing file\nError: ${err}`); - } -}; \ No newline at end of file + // Attempt to write the JSON content to file + try { + await writeFile(writePath, JSON.stringify(jsonContent)); + } catch (err) { + throw new Error(`Error while writing file\nError: ${err}`); + } +}; From 2badba708c2dc63498e9ea71bae30e84b748ae7a Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Sat, 16 Nov 2024 15:04:44 +0530 Subject: [PATCH 02/59] format using prettier --- scripts/adopters/index.js | 5 +- scripts/build-docs.js | 67 +++++++++------------ scripts/build-meetings.js | 23 +++---- scripts/build-newsroom-videos.js | 21 +++---- scripts/build-post-list.js | 87 ++++++++------------------- scripts/build-rss.js | 18 ++---- scripts/build-tools.js | 33 +++------- scripts/casestudies/index.js | 13 ++-- scripts/compose.js | 33 ++++------ scripts/dashboard/build-dashboard.js | 75 ++++++++--------------- scripts/dashboard/issue-queries.js | 2 +- scripts/finance/index.js | 33 ++-------- scripts/index.js | 14 +---- scripts/markdown/check-markdown.js | 18 +----- scripts/tools/categorylist.js | 53 ++++++---------- scripts/tools/combine-tools.js | 82 ++++++++++--------------- scripts/tools/extract-tools-github.js | 15 ++--- scripts/tools/tags-color.js | 72 +++++++++++----------- scripts/tools/tools-object.js | 81 +++++++++---------------- scripts/utils.js | 4 +- scripts/utils/readAndWriteJson.js | 2 +- 21 files changed, 261 insertions(+), 490 deletions(-) diff --git a/scripts/adopters/index.js b/scripts/adopters/index.js index ef6643802d62..a8c8363d25ab 100644 --- a/scripts/adopters/index.js +++ b/scripts/adopters/index.js @@ -2,8 +2,5 @@ const { resolve } = require('path'); const writeJSON = require('../utils/readAndWriteJson.js'); module.exports = async function buildAdoptersList() { - writeJSON( - 'config/adopters.yml', - resolve(__dirname, '../../config', 'adopters.json'), - ); + writeJSON('config/adopters.yml', resolve(__dirname, '../../config', 'adopters.json')); }; diff --git a/scripts/build-docs.js b/scripts/build-docs.js index e1aff2f99cd1..48693f176ba8 100644 --- a/scripts/build-docs.js +++ b/scripts/build-docs.js @@ -1,4 +1,5 @@ const sortBy = require('lodash/sortBy'); + function buildNavTree(navItems) { try { const tree = { @@ -10,42 +11,36 @@ function buildNavTree(navItems) { isSection: true, rootSectionId: 'welcome', sectionWeight: 0, - slug: '/docs', + slug: '/docs' }, - children: {}, - }, + children: {} + } }; - //first we make sure that list of items lists main section items and then sub sections, documents last - const sortedItems = sortBy(navItems, [ - 'isRootSection', - 'weight', - 'isSection', - ]); + // first we make sure that list of items lists main section items and then sub sections, documents last + const sortedItems = sortBy(navItems, ['isRootSection', 'weight', 'isSection']); sortedItems.forEach((item) => { - //identify main sections + // identify main sections if (item.isRootSection) { tree[item.rootSectionId] = { item, children: {} }; } - //identify subsections + // identify subsections if (item.parent) { if (!tree[item.parent]) { - throw new Error( - `Parent section ${item.parent} not found for item ${item.title}`, - ); + throw new Error(`Parent section ${item.parent} not found for item ${item.title}`); } tree[item.parent].children[item.sectionId] = { item, children: [] }; } if (!item.isSection) { if (item.sectionId) { - let section = tree[item.rootSectionId]?.children[item.sectionId]; + const section = tree[item.rootSectionId]?.children[item.sectionId]; if (!section) { tree[item.rootSectionId].children[item.sectionId] = { item, - children: [], + children: [] }; } tree[item.rootSectionId].children[item.sectionId].children.push(item); @@ -68,7 +63,7 @@ function buildNavTree(navItems) { return obj; }, {}); - //handling subsections + // handling subsections if (allChildrenKeys.length > 1) { for (const key of allChildrenKeys) { if (allChildren[key].children) { @@ -79,9 +74,7 @@ function buildNavTree(navItems) { // point in slug for specification subgroup to the latest specification version if (rootKey === 'reference' && key === 'specification') { - allChildren[key].item.href = allChildren[key].children.find( - (c) => c.isPrerelease === undefined, - ).slug; + allChildren[key].item.href = allChildren[key].children.find((c) => c.isPrerelease === undefined).slug; } } } @@ -101,9 +94,9 @@ const convertDocPosts = (docObject) => { // certain entries in the DocPosts are either a parent to many posts or itself a post. docsArray.push(docObject?.item || docObject); if (docObject.children) { - let children = docObject.children; + const { children } = docObject; Object.keys(children).forEach((child) => { - let docChildArray = convertDocPosts(children[child]); + const docChildArray = convertDocPosts(children[child]); docsArray = [...docsArray, ...docChildArray]; }); } @@ -115,16 +108,16 @@ const convertDocPosts = (docObject) => { function addDocButtons(docPosts, treePosts) { let structuredPosts = []; - let rootSections = []; + const rootSections = []; try { // Traversing the whole DocTree and storing each post inside them in sequential order Object.keys(treePosts).forEach((rootElement) => { structuredPosts.push(treePosts[rootElement].item); if (treePosts[rootElement].children) { - let children = treePosts[rootElement].children; + const { children } = treePosts[rootElement]; Object.keys(children).forEach((child) => { - let docChildArray = convertDocPosts(children[child]); + const docChildArray = convertDocPosts(children[child]); structuredPosts = [...structuredPosts, ...docChildArray]; }); } @@ -134,7 +127,7 @@ function addDocButtons(docPosts, treePosts) { structuredPosts[0] = docPosts.filter((p) => p.slug === '/docs')[0]; // Traversing the structuredPosts in order to add `nextPage` and `prevPage` details for each page - let countDocPages = structuredPosts.length; + const countDocPages = structuredPosts.length; structuredPosts = structuredPosts.map((post, index) => { // post item specifying the root Section or sub-section in the docs are excluded as // they doesn't comprise any Doc Page or content to be shown in website. @@ -143,26 +136,23 @@ function addDocButtons(docPosts, treePosts) { return post; } - let nextPage = {}, - prevPage = {}; + let nextPage = {}; + let prevPage = {}; let docPost = post; // checks whether the next page for the current docPost item exists or not if (index + 1 < countDocPages) { // checks whether the next item inside structuredPosts is a rootElement or a sectionElement // if yes, it goes again to a next to next item in structuredPosts to link the nextPage - if ( - !structuredPosts[index + 1].isRootElement && - !structuredPosts[index + 1].isSection - ) { + if (!structuredPosts[index + 1].isRootElement && !structuredPosts[index + 1].isSection) { nextPage = { title: structuredPosts[index + 1].title, - href: structuredPosts[index + 1].slug, + href: structuredPosts[index + 1].slug }; } else { nextPage = { title: `${structuredPosts[index + 1].title} - ${structuredPosts[index + 2].title}`, - href: structuredPosts[index + 2].slug, + href: structuredPosts[index + 2].slug }; } docPost = { ...docPost, nextPage }; @@ -172,13 +162,10 @@ function addDocButtons(docPosts, treePosts) { if (index > 0) { // checks whether the previous item inside structuredPosts is a rootElement or a sectionElement // if yes, it goes again to a next previous item in structuredPosts to link the prevPage - if ( - !structuredPosts[index - 1]?.isRootElement && - !structuredPosts[index - 1]?.isSection - ) { + if (!structuredPosts[index - 1]?.isRootElement && !structuredPosts[index - 1]?.isSection) { prevPage = { title: structuredPosts[index - 1].title, - href: structuredPosts[index - 1].slug, + href: structuredPosts[index - 1].slug }; docPost = { ...docPost, prevPage }; } else { @@ -186,7 +173,7 @@ function addDocButtons(docPosts, treePosts) { if (index - 2 >= 0) { prevPage = { title: `${structuredPosts[index - 1]?.isRootSection ? rootSections[rootSections.length - 2] : rootSections[rootSections.length - 1]} - ${structuredPosts[index - 2].title}`, - href: structuredPosts[index - 2].slug, + href: structuredPosts[index - 2].slug }; docPost = { ...docPost, prevPage }; } diff --git a/scripts/build-meetings.js b/scripts/build-meetings.js index cc56c0d026b8..ac556b7578d4 100644 --- a/scripts/build-meetings.js +++ b/scripts/build-meetings.js @@ -9,9 +9,7 @@ async function buildMeetings(writePath) { try { auth = new google.auth.GoogleAuth({ scopes: ['https://www.googleapis.com/auth/calendar'], - credentials: process.env.CALENDAR_SERVICE_ACCOUNT - ? JSON.parse(process.env.CALENDAR_SERVICE_ACCOUNT) - : undefined, + credentials: process.env.CALENDAR_SERVICE_ACCOUNT ? JSON.parse(process.env.CALENDAR_SERVICE_ACCOUNT) : undefined }); calendar = google.calendar({ version: 'v3', auth }); @@ -22,19 +20,15 @@ async function buildMeetings(writePath) { let eventsItems; try { - //cron job runs this always on midnight + // cron job runs this always on midnight const currentTime = new Date(Date.now()).toISOString(); - const timeMin = new Date( - Date.parse(currentTime) - 100 * 24 * 60 * 60 * 1000, - ).toISOString(); - const timeMax = new Date( - Date.parse(currentTime) + 30 * 24 * 60 * 60 * 1000, - ).toISOString(); + const timeMin = new Date(Date.parse(currentTime) - 100 * 24 * 60 * 60 * 1000).toISOString(); + const timeMax = new Date(Date.parse(currentTime) + 30 * 24 * 60 * 60 * 1000).toISOString(); const eventsList = await calendar.events.list({ calendarId: process.env.CALENDAR_ID, - timeMax: timeMax, - timeMin: timeMin, + timeMax, + timeMin }); eventsItems = eventsList.data.items.map((e) => { @@ -44,9 +38,8 @@ async function buildMeetings(writePath) { url: e.extendedProperties?.private && `https://github.com/asyncapi/community/issues/${e.extendedProperties.private.ISSUE_ID}`, - banner: - e.extendedProperties?.private && e.extendedProperties.private.BANNER, - date: new Date(e.start.dateTime), + banner: e.extendedProperties?.private && e.extendedProperties.private.BANNER, + date: new Date(e.start.dateTime) }; }); diff --git a/scripts/build-newsroom-videos.js b/scripts/build-newsroom-videos.js index 496eba2de769..40ad1617362e 100644 --- a/scripts/build-newsroom-videos.js +++ b/scripts/build-newsroom-videos.js @@ -5,16 +5,15 @@ const fetch = require('node-fetch-2'); async function buildNewsroomVideos(writePath) { try { const response = await fetch( - 'https://youtube.googleapis.com/youtube/v3/search?' + - new URLSearchParams({ - key: process.env.YOUTUBE_TOKEN, - part: 'snippet', - channelId: 'UCIz9zGwDLbrYQcDKVXdOstQ', - eventType: 'completed', - type: 'video', - order: 'Date', - maxResults: 5, - }), + `https://youtube.googleapis.com/youtube/v3/search?${new URLSearchParams({ + key: process.env.YOUTUBE_TOKEN, + part: 'snippet', + channelId: 'UCIz9zGwDLbrYQcDKVXdOstQ', + eventType: 'completed', + type: 'video', + order: 'Date', + maxResults: 5 + })}` ); if (!response.ok) { @@ -32,7 +31,7 @@ async function buildNewsroomVideos(writePath) { image_url: video.snippet.thumbnails.high.url, title: video.snippet.title, description: video.snippet.description, - videoId: video.id.videoId, + videoId: video.id.videoId })); const videoData = JSON.stringify(videoDataItems, null, ' '); diff --git a/scripts/build-post-list.js b/scripts/build-post-list.js index dc249c6e2a43..3cfee35032ec 100644 --- a/scripts/build-post-list.js +++ b/scripts/build-post-list.js @@ -1,10 +1,4 @@ -const { - readdirSync, - statSync, - existsSync, - readFileSync, - writeFileSync, -} = require('fs'); +const { readdirSync, statSync, existsSync, readFileSync, writeFileSync } = require('fs'); const { resolve, basename } = require('path'); const frontMatter = require('gray-matter'); const toc = require('markdown-toc'); @@ -18,7 +12,7 @@ const result = { docs: [], blog: [], about: [], - docsTree: {}, + docsTree: {} }; const releaseNotes = []; const basePath = 'pages'; @@ -26,47 +20,35 @@ const postDirectories = [ // order of these directories is important, as the blog should come before docs, to create a list of available release notes, which will later be used to release-note-link for spec docs [`${basePath}/blog`, '/blog'], [`${basePath}/docs`, '/docs'], - [`${basePath}/about`, '/about'], + [`${basePath}/about`, '/about'] ]; const addItem = (details) => { - if (details.slug.startsWith('/docs')) result['docs'].push(details); - else if (details.slug.startsWith('/blog')) result['blog'].push(details); - else if (details.slug.startsWith('/about')) result['about'].push(details); + if (details.slug.startsWith('/docs')) result.docs.push(details); + else if (details.slug.startsWith('/blog')) result.blog.push(details); + else if (details.slug.startsWith('/about')) result.about.push(details); else { } }; module.exports = async function buildPostList() { walkDirectories(postDirectories, result); - const treePosts = buildNavTree( - result['docs'].filter((p) => p.slug.startsWith('/docs/')), - ); - result['docsTree'] = treePosts; - result['docs'] = addDocButtons(result['docs'], treePosts); + const treePosts = buildNavTree(result.docs.filter((p) => p.slug.startsWith('/docs/'))); + result.docsTree = treePosts; + result.docs = addDocButtons(result.docs, treePosts); if (process.env.NODE_ENV === 'production') { // console.log(inspect(result, { depth: null, colors: true })) } - writeFileSync( - resolve(__dirname, '..', 'config', 'posts.json'), - JSON.stringify(result, null, ' '), - ); + writeFileSync(resolve(__dirname, '..', 'config', 'posts.json'), JSON.stringify(result, null, ' ')); }; -function walkDirectories( - directories, - result, - sectionWeight = 0, - sectionTitle, - sectionId, - rootSectionId, -) { - for (let dir of directories) { - let directory = dir[0]; - let sectionSlug = dir[1] || ''; - let files = readdirSync(directory); +function walkDirectories(directories, result, sectionWeight = 0, sectionTitle, sectionId, rootSectionId) { + for (const dir of directories) { + const directory = dir[0]; + const sectionSlug = dir[1] || ''; + const files = readdirSync(directory); - for (let file of files) { + for (const file of files) { let details; const fileName = [directory, file].join('/'); const fileNameWithSection = [fileName, '_section.mdx'].join('/'); @@ -75,14 +57,11 @@ function walkDirectories( if (isDirectory(fileName)) { if (existsSync(fileNameWithSection)) { // Passing a second argument to frontMatter disables cache. See https://github.com/asyncapi/website/issues/1057 - details = frontMatter( - readFileSync(fileNameWithSection, 'utf-8'), - {}, - ).data; + details = frontMatter(readFileSync(fileNameWithSection, 'utf-8'), {}).data; details.title = details.title || capitalize(basename(fileName)); } else { details = { - title: capitalize(basename(fileName)), + title: capitalize(basename(fileName)) }; } details.isSection = true; @@ -98,14 +77,7 @@ function walkDirectories( details.slug = slug; addItem(details); const rootId = details.parent || details.rootSectionId; - walkDirectories( - [[fileName, slug]], - result, - details.weight, - details.title, - details.sectionId, - rootId, - ); + walkDirectories([[fileName, slug]], result, details.weight, details.title, details.sectionId, rootId); } else if (file.endsWith('.mdx') && !fileName.endsWith('/_section.mdx')) { const fileContent = readFileSync(fileName, 'utf-8'); // Passing a second argument to frontMatter disables cache. See https://github.com/asyncapi/website/issues/1057 @@ -113,8 +85,7 @@ function walkDirectories( details = data; details.toc = toc(content, { slugify: slugifyToC }).json; details.readingTime = Math.ceil(readingTime(content).minutes); - details.excerpt = - details.excerpt || markdownToTxt(content).substr(0, 200); + details.excerpt = details.excerpt || markdownToTxt(content).substr(0, 200); details.sectionSlug = sectionSlug || slug.replace(/\.mdx$/, ''); details.sectionWeight = sectionWeight; details.sectionTitle = sectionTitle; @@ -122,13 +93,8 @@ function walkDirectories( details.rootSectionId = rootSectionId; details.id = fileName; details.isIndex = fileName.endsWith('/index.mdx'); - details.slug = details.isIndex - ? sectionSlug - : slug.replace(/\.mdx$/, ''); - if ( - details.slug.includes('/reference/specification/') && - !details.title - ) { + details.slug = details.isIndex ? sectionSlug : slug.replace(/\.mdx$/, ''); + if (details.slug.includes('/reference/specification/') && !details.title) { const fileBaseName = basename(data.slug); // ex. v2.0.0 | v2.1.0-next-spec.1 const fileName = fileBaseName.split('-')[0]; // v2.0.0 | v2.1.0 details.weight = specWeight--; @@ -143,10 +109,7 @@ function walkDirectories( details.releaseNoteLink = `/blog/release-notes-${details.title}`; } - if ( - fileBaseName.includes('next-spec') || - fileBaseName.includes('next-major-spec') - ) { + if (fileBaseName.includes('next-spec') || fileBaseName.includes('next-major-spec')) { details.isPrerelease = true; // this need to be separate because the `-` in "Pre-release" will get removed by `capitalize()` function details.title += ' (Pre-release)'; @@ -160,9 +123,7 @@ function walkDirectories( if (file.startsWith('release-notes') && dir[1] === '/blog') { const fileName_without_extension = file.slice(0, -4); // removes the file extension. For example, release-notes-2.1.0.md -> release-notes-2.1.0 - const version = fileName_without_extension.slice( - fileName_without_extension.lastIndexOf('-') + 1, - ); + const version = fileName_without_extension.slice(fileName_without_extension.lastIndexOf('-') + 1); // gets the version from the name of the releaseNote .md file (from /blog). For example, version = 2.1.0 if fileName_without_extension = release-notes-2.1.0 releaseNotes.push(version); diff --git a/scripts/build-rss.js b/scripts/build-rss.js index 46c668119c6a..75195ea53ccf 100644 --- a/scripts/build-rss.js +++ b/scripts/build-rss.js @@ -29,9 +29,7 @@ module.exports = async function rssFeed(type, title, desc, outputPath) { }); if (missingDatePosts.length > 0) { - throw new Error( - `Missing date in posts: ${missingDatePosts.map((p) => p.title || p.slug).join(', ')}`, - ); + throw new Error(`Missing date in posts: ${missingDatePosts.map((p) => p.title || p.slug).join(', ')}`); } const base = 'https://www.asyncapi.com'; @@ -56,17 +54,13 @@ module.exports = async function rssFeed(type, title, desc, outputPath) { rss.channel.generator = 'next.js'; rss.channel.item = []; - const invalidPosts = posts.filter( - (post) => !post.title || !post.slug || !post.excerpt || !post.date, - ); + const invalidPosts = posts.filter((post) => !post.title || !post.slug || !post.excerpt || !post.date); if (invalidPosts.length > 0) { - throw new Error( - `Missing required fields in posts: ${invalidPosts.map((p) => p.title || p.slug).join(', ')}`, - ); + throw new Error(`Missing required fields in posts: ${invalidPosts.map((p) => p.title || p.slug).join(', ')}`); } - for (let post of posts) { + for (const post of posts) { const link = `${base}${post.slug}${tracking}`; const { title, excerpt, date } = post; const pubDate = new Date(date).toUTCString(); @@ -78,7 +72,7 @@ module.exports = async function rssFeed(type, title, desc, outputPath) { link, category: type, guid, - pubDate, + pubDate }; if (post.cover) { const enclosure = {}; @@ -86,7 +80,7 @@ module.exports = async function rssFeed(type, title, desc, outputPath) { enclosure['@length'] = 15026; // dummy value, anything works enclosure['@type'] = 'image/jpeg'; if (typeof enclosure['@url'] === 'string') { - let tmp = enclosure['@url'].toLowerCase(); + const tmp = enclosure['@url'].toLowerCase(); if (tmp.indexOf('.png') >= 0) enclosure['@type'] = 'image/png'; if (tmp.indexOf('.svg') >= 0) enclosure['@type'] = 'image/svg+xml'; if (tmp.indexOf('.webp') >= 0) enclosure['@type'] = 'image/webp'; diff --git a/scripts/build-tools.js b/scripts/build-tools.js index 30404a2d015f..83db76534f11 100644 --- a/scripts/build-tools.js +++ b/scripts/build-tools.js @@ -1,30 +1,17 @@ +const fs = require('fs-extra'); +const { resolve } = require('path'); const { getData } = require('./tools/extract-tools-github'); const { convertTools } = require('./tools/tools-object'); const { combineTools } = require('./tools/combine-tools'); -const fs = require('fs-extra'); -const { resolve } = require('path'); -const buildTools = async ( - automatedToolsPath, - manualToolsPath, - toolsPath, - tagsPath, -) => { +const buildTools = async (automatedToolsPath, manualToolsPath, toolsPath, tagsPath) => { try { - let githubExtractData = await getData(); - let automatedTools = await convertTools(githubExtractData); + const githubExtractData = await getData(); + const automatedTools = await convertTools(githubExtractData); - await fs.writeFile( - automatedToolsPath, - JSON.stringify(automatedTools, null, ' '), - ); + await fs.writeFile(automatedToolsPath, JSON.stringify(automatedTools, null, ' ')); - await combineTools( - automatedTools, - require(manualToolsPath), - toolsPath, - tagsPath, - ); + await combineTools(automatedTools, require(manualToolsPath), toolsPath, tagsPath); } catch (err) { throw new Error(`An error occurred while building tools: ${err.message}`); } @@ -32,11 +19,7 @@ const buildTools = async ( /* istanbul ignore next */ if (require.main === module) { - const automatedToolsPath = resolve( - __dirname, - '../config', - 'tools-automated.json', - ); + 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'); diff --git a/scripts/casestudies/index.js b/scripts/casestudies/index.js index 3ff9e415f525..22011781f1be 100644 --- a/scripts/casestudies/index.js +++ b/scripts/casestudies/index.js @@ -1,14 +1,11 @@ const { readdir, writeFile, readFile } = require('fs').promises; -const { convertToJson } = require('../../scripts/utils'); +const { convertToJson } = require('../utils'); -module.exports = async function buildCaseStudiesList( - dirWithCaseStudy, - writeFilePath, -) { +module.exports = async function buildCaseStudiesList(dirWithCaseStudy, writeFilePath) { try { - let files = await readdir(dirWithCaseStudy); - let caseStudiesList = []; - for (let file of files) { + const files = await readdir(dirWithCaseStudy); + const caseStudiesList = []; + for (const file of files) { const caseStudyFileName = [dirWithCaseStudy, file].join('/'); const caseStudyContent = await readFile(caseStudyFileName, 'utf-8'); const jsonContent = convertToJson(caseStudyContent); diff --git a/scripts/compose.js b/scripts/compose.js index 00d262019428..18d8d724420d 100644 --- a/scripts/compose.js +++ b/scripts/compose.js @@ -8,15 +8,11 @@ const dedent = require('dedent'); const moment = require('moment'); const genFrontMatter = (answers) => { - let d = new Date(); - const date = [ - d.getFullYear(), - ('0' + (d.getMonth() + 1)).slice(-2), - ('0' + d.getDate()).slice(-2), - ].join('-'); + const d = new Date(); + const date = [d.getFullYear(), `0${d.getMonth() + 1}`.slice(-2), `0${d.getDate()}`.slice(-2)].join('-'); const tagArray = answers.tags.split(','); tagArray.forEach((tag, index) => (tagArray[index] = tag.trim())); - const tags = "'" + tagArray.join("','") + "'"; + const tags = `'${tagArray.join("','")}'`; let frontMatter = dedent`--- title: ${answers.title ? answers.title : 'Untitled'} @@ -92,7 +88,7 @@ const genFrontMatter = (answers) => { `; - frontMatter = frontMatter + '\n---'; + frontMatter += '\n---'; return frontMatter; }; @@ -102,36 +98,29 @@ inquirer { name: 'title', message: 'Enter post title:', - type: 'input', + type: 'input' }, { name: 'excerpt', message: 'Enter post excerpt:', - type: 'input', + type: 'input' }, { name: 'tags', message: 'Any Tags? Separate them with , or leave empty if no tags.', - type: 'input', + type: 'input' }, { name: 'type', message: 'Enter the post type:', type: 'list', - choices: [ - 'Communication', - 'Community', - 'Engineering', - 'Marketing', - 'Strategy', - 'Video', - ], + choices: ['Communication', 'Community', 'Engineering', 'Marketing', 'Strategy', 'Video'] }, { name: 'canonical', message: 'Enter the canonical URL if any:', - type: 'input', - }, + type: 'input' + } ]) .then((answers) => { // Remove special characters and replace space with - @@ -141,7 +130,7 @@ inquirer .replace(/ /g, '-') .replace(/-+/g, '-'); const frontMatter = genFrontMatter(answers); - const filePath = `pages/blog/${fileName ? fileName : 'untitled'}.md`; + const filePath = `pages/blog/${fileName || 'untitled'}.md`; fs.writeFile(filePath, frontMatter, { flag: 'wx' }, (err) => { if (err) { throw err; diff --git a/scripts/dashboard/build-dashboard.js b/scripts/dashboard/build-dashboard.js index cb07d85c2f5f..00e2049a6338 100644 --- a/scripts/dashboard/build-dashboard.js +++ b/scripts/dashboard/build-dashboard.js @@ -20,8 +20,8 @@ async function getDiscussions(query, pageSize, endCursor = null) { first: pageSize, after: endCursor, headers: { - authorization: `token ${process.env.GITHUB_TOKEN}`, - }, + authorization: `token ${process.env.GITHUB_TOKEN}` + } }); if (result.rateLimit.remaining <= 100) { @@ -30,7 +30,7 @@ async function getDiscussions(query, pageSize, endCursor = null) { `cost = ${result.rateLimit.cost}`, `limit = ${result.rateLimit.limit}`, `remaining = ${result.rateLimit.remaining}`, - `resetAt = ${result.rateLimit.resetAt}`, + `resetAt = ${result.rateLimit.resetAt}` ); } @@ -41,9 +41,7 @@ async function getDiscussions(query, pageSize, endCursor = null) { if (!hasNextPage) { return result.search.nodes; } - return result.search.nodes.concat( - await getDiscussions(query, pageSize, result.search.pageInfo.endCursor), - ); + return result.search.nodes.concat(await getDiscussions(query, pageSize, result.search.pageInfo.endCursor)); } catch (e) { console.error(e); return Promise.reject(e); @@ -52,15 +50,12 @@ async function getDiscussions(query, pageSize, endCursor = null) { async function getDiscussionByID(isPR, id) { try { - const result = await graphql( - isPR ? Queries.pullRequestById : Queries.issueById, - { - id, - headers: { - authorization: `token ${process.env.GITHUB_TOKEN}`, - }, - }, - ); + const result = await graphql(isPR ? Queries.pullRequestById : Queries.issueById, { + id, + headers: { + authorization: `token ${process.env.GITHUB_TOKEN}` + } + }); return result; } catch (e) { @@ -75,28 +70,19 @@ async function processHotDiscussions(batch) { try { const isPR = discussion.__typename === 'PullRequest'; if (discussion.comments.pageInfo.hasNextPage) { - const fetchedDiscussion = await getDiscussionByID( - isPR, - discussion.id, - ); + const fetchedDiscussion = await getDiscussionByID(isPR, discussion.id); discussion = fetchedDiscussion.node; } const interactionsCount = discussion.reactions.totalCount + discussion.comments.totalCount + - discussion.comments.nodes.reduce( - (acc, curr) => acc + curr.reactions.totalCount, - 0, - ); + discussion.comments.nodes.reduce((acc, curr) => acc + curr.reactions.totalCount, 0); const finalInteractionsCount = isPR ? interactionsCount + discussion.reviews.totalCount + - discussion.reviews.nodes.reduce( - (acc, curr) => acc + curr.comments.totalCount, - 0, - ) + discussion.reviews.nodes.reduce((acc, curr) => acc + curr.comments.totalCount, 0) : interactionsCount; return { @@ -108,17 +94,13 @@ async function processHotDiscussions(batch) { resourcePath: discussion.resourcePath, repo: `asyncapi/${discussion.repository.name}`, labels: discussion.labels ? discussion.labels.nodes : [], - score: - finalInteractionsCount / - (monthsSince(discussion.timelineItems.updatedAt) + 2) ** 1.8, + score: finalInteractionsCount / (monthsSince(discussion.timelineItems.updatedAt) + 2) ** 1.8 }; } catch (e) { - console.error( - `there were some issues while parsing this item: ${JSON.stringify(discussion)}`, - ); + console.error(`there were some issues while parsing this item: ${JSON.stringify(discussion)}`); throw e; } - }), + }) ); } @@ -134,9 +116,7 @@ async function getHotDiscussions(discussions) { } result.sort((ElemA, ElemB) => ElemB.score - ElemA.score); - const filteredResult = result.filter( - (issue) => issue.author !== 'asyncapi-bot', - ); + const filteredResult = result.filter((issue) => issue.author !== 'asyncapi-bot'); return filteredResult.slice(0, 12); } @@ -146,7 +126,7 @@ async function writeToFile(content, writePath) { } catch (error) { console.error('Failed to write dashboard data:', { error: error.message, - writePath, + writePath }); throw error; } @@ -162,17 +142,13 @@ async function mapGoodFirstIssues(issues) { author: issue.author.login, area: getLabel(issue, 'area/') || 'Unknown', labels: issue.labels.nodes.filter( - (label) => - !label.name.startsWith('area/') && - !label.name.startsWith('good first issue'), - ), + (label) => !label.name.startsWith('area/') && !label.name.startsWith('good first issue') + ) })); } function getLabel(issue, filter) { - const result = issue.labels.nodes.find((label) => - label.name.startsWith(filter), - ); + const result = issue.labels.nodes.find((label) => label.name.startsWith(filter)); return result?.name.split('/')[1]; } @@ -187,14 +163,11 @@ async function start(writePath) { try { const issues = await getDiscussions(Queries.hotDiscussionsIssues, 20); const PRs = await getDiscussions(Queries.hotDiscussionsPullRequests, 20); - const rawGoodFirstIssues = await getDiscussions( - Queries.goodFirstIssues, - 20, - ); + const rawGoodFirstIssues = await getDiscussions(Queries.goodFirstIssues, 20); const discussions = issues.concat(PRs); const [hotDiscussions, goodFirstIssues] = await Promise.all([ getHotDiscussions(discussions), - mapGoodFirstIssues(rawGoodFirstIssues), + mapGoodFirstIssues(rawGoodFirstIssues) ]); return await writeToFile({ hotDiscussions, goodFirstIssues }, writePath); } catch (e) { @@ -217,5 +190,5 @@ module.exports = { getDiscussions, writeToFile, start, - processHotDiscussions, + processHotDiscussions }; diff --git a/scripts/dashboard/issue-queries.js b/scripts/dashboard/issue-queries.js index 629214a9ea90..4b2e5a87853c 100644 --- a/scripts/dashboard/issue-queries.js +++ b/scripts/dashboard/issue-queries.js @@ -274,5 +274,5 @@ query($first: Int!, $after: String) { resetAt } } -`, +` }); diff --git a/scripts/finance/index.js b/scripts/finance/index.js index af3cf0a80f60..c5ab35346c0d 100644 --- a/scripts/finance/index.js +++ b/scripts/finance/index.js @@ -1,39 +1,16 @@ const { - promises: { mkdir }, + promises: { mkdir } } = require('fs'); const { resolve } = require('path'); const writeJSON = require('../utils/readAndWriteJson.js'); -module.exports = async function buildFinanceInfoList({ - currentDir, - configDir, - financeDir, - year, - jsonDataDir, -}) { +module.exports = async function buildFinanceInfoList({ currentDir, configDir, financeDir, year, jsonDataDir }) { try { - const expensesPath = resolve( - currentDir, - configDir, - financeDir, - year, - 'Expenses.yml', - ); - const expensesLinkPath = resolve( - currentDir, - configDir, - financeDir, - year, - 'ExpensesLink.yml', - ); + const expensesPath = resolve(currentDir, configDir, financeDir, year, 'Expenses.yml'); + const expensesLinkPath = resolve(currentDir, configDir, financeDir, year, 'ExpensesLink.yml'); // Ensure the directory exists before writing the files - const jsonDirectory = resolve( - currentDir, - configDir, - financeDir, - jsonDataDir, - ); + const jsonDirectory = resolve(currentDir, configDir, financeDir, jsonDataDir); await mkdir(jsonDirectory, { recursive: true }); // Write Expenses and ExpensesLink to JSON files diff --git a/scripts/index.js b/scripts/index.js index 0ae68666ce24..afe99ff7ca11 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -8,16 +8,8 @@ const buildFinanceInfoList = require('./finance'); async function start() { await buildPostList(); - rssFeed( - 'blog', - 'AsyncAPI Initiative Blog RSS Feed', - 'AsyncAPI Initiative Blog', - 'rss.xml', - ); - await buildCaseStudiesList( - 'config/casestudies', - resolve(__dirname, '../config', 'case-studies.json'), - ); + rssFeed('blog', 'AsyncAPI Initiative Blog RSS Feed', 'AsyncAPI Initiative Blog', 'rss.xml'); + await buildCaseStudiesList('config/casestudies', resolve(__dirname, '../config', 'case-studies.json')); await buildAdoptersList(); const financeDir = resolve('.', 'config', 'finance'); @@ -44,7 +36,7 @@ async function start() { configDir: 'config', financeDir: 'finance', year: latestYear, - jsonDataDir: 'json-data', + jsonDataDir: 'json-data' }); } diff --git a/scripts/markdown/check-markdown.js b/scripts/markdown/check-markdown.js index 001a210a2a77..7088a1c4d0fc 100644 --- a/scripts/markdown/check-markdown.js +++ b/scripts/markdown/check-markdown.js @@ -23,14 +23,7 @@ function isValidURL(str) { * @returns {string[]|null} An array of validation error messages, or null if no errors. */ function validateBlogs(frontmatter) { - const requiredAttributes = [ - 'title', - 'date', - 'type', - 'tags', - 'cover', - 'authors', - ]; + const requiredAttributes = ['title', 'date', 'type', 'tags', 'cover', 'authors']; const errors = []; // Check for required attributes @@ -65,9 +58,7 @@ function validateBlogs(frontmatter) { errors.push(`Author at index ${index} is missing a name`); } if (author.link && !isValidURL(author.link)) { - errors.push( - `Invalid URL for author at index ${index}: ${author.link}`, - ); + errors.push(`Invalid URL for author at index ${index}: ${author.link}`); } if (!author.photo) { errors.push(`Author at index ${index} is missing a photo`); @@ -94,10 +85,7 @@ function validateDocs(frontmatter) { } // Check if weight exists and is a number - if ( - frontmatter.weight === undefined || - typeof frontmatter.weight !== 'number' - ) { + if (frontmatter.weight === undefined || typeof frontmatter.weight !== 'number') { errors.push('Weight is missing or not a number'); } diff --git a/scripts/tools/categorylist.js b/scripts/tools/categorylist.js index 15323b1606aa..dc81be15a320 100644 --- a/scripts/tools/categorylist.js +++ b/scripts/tools/categorylist.js @@ -3,117 +3,104 @@ const categoryList = [ { name: 'APIs', tag: 'api', - description: - 'The following is a list of APIs that expose functionality related to AsyncAPI.', + description: 'The following is a list of APIs that expose functionality related to AsyncAPI.' }, { name: 'Code-first tools', tag: 'code-first', - description: - 'The following is a list of tools that generate AsyncAPI documents from your code.', + description: 'The following is a list of tools that generate AsyncAPI documents from your code.' }, { name: 'Code Generators', tag: 'code-generator', description: - 'The following is a list of tools that generate code from an AsyncAPI document; not the other way around.', + 'The following is a list of tools that generate code from an AsyncAPI document; not the other way around.' }, { name: 'Converters', tag: 'converter', description: - 'The following is a list of tools that do not yet belong to any specific category but are also useful for the community.', + 'The following is a list of tools that do not yet belong to any specific category but are also useful for the community.' }, { name: 'Directories', tag: 'directory', - description: - 'The following is a list of directories that index public AsyncAPI documents.', + description: 'The following is a list of directories that index public AsyncAPI documents.' }, { name: 'Documentation Generators', tag: 'documentation-generator', description: - 'The following is a list of tools that generate human-readable documentation from an AsyncAPI document.', + 'The following is a list of tools that generate human-readable documentation from an AsyncAPI document.' }, { name: 'Editors', tag: 'editor', - description: - 'The following is a list of editors or related tools that allow editing of AsyncAPI document.', + description: 'The following is a list of editors or related tools that allow editing of AsyncAPI document.' }, { name: 'UI components', tag: 'ui-component', - description: - 'The following is a list of UI components to view AsyncAPI documents.', + description: 'The following is a list of UI components to view AsyncAPI documents.' }, { name: 'DSL', tag: '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.", + "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." }, { name: 'Frameworks', tag: 'framework', - description: - 'The following is a list of API/application frameworks that make use of AsyncAPI.', + description: 'The following is a list of API/application frameworks that make use of AsyncAPI.' }, { name: 'GitHub Actions', tag: 'github-action', - description: - 'The following is a list of GitHub Actions that you can use in your workflows', + description: 'The following is a list of GitHub Actions that you can use in your workflows' }, { name: 'Mocking and Testing', tag: '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.', + '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.' }, { name: 'Validators', tag: 'validator', - description: - 'The following is a list of tools that validate AsyncAPI documents.', + description: 'The following is a list of tools that validate AsyncAPI documents.' }, { name: 'Compare tools', tag: 'compare-tool', - description: - 'The following is a list of tools that compare AsyncAPI documents.', + description: 'The following is a list of tools that compare AsyncAPI documents.' }, { name: 'CLIs', tag: 'cli', - description: - 'The following is a list of tools that you can work with in terminal or do some CI/CD automation.', + description: 'The following is a list of tools that you can work with in terminal or do some CI/CD automation.' }, { name: 'Bundlers', tag: 'bundler', - description: - 'The following is a list of tools that you can work with to bundle AsyncAPI documents.', + description: 'The following is a list of tools that you can work with to bundle AsyncAPI documents.' }, { name: 'IDE Extensions', tag: 'ide-extension', - description: - 'The following is a list of extensions for different IDEs like VSCode, IntelliJ IDEA and others', + description: 'The following is a list of extensions for different IDEs like VSCode, IntelliJ IDEA and others' }, { name: 'AsyncAPI Generator Templates', tag: 'generator-template', 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.', + '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.' }, { name: 'Others', tag: 'other', - description: - 'The following is a list of tools that comes under Other category.', - }, + description: 'The following is a list of tools that comes under Other category.' + } ]; module.exports = { categoryList }; diff --git a/scripts/tools/combine-tools.js b/scripts/tools/combine-tools.js index 34980f1abd61..01be1ec876dc 100644 --- a/scripts/tools/combine-tools.js +++ b/scripts/tools/combine-tools.js @@ -1,20 +1,21 @@ -const { languagesColor, technologiesColor } = require('./tags-color'); -const { categoryList } = require('./categorylist.js'); -const { createToolObject } = require('./tools-object'); const fs = require('fs'); -const schema = require('./tools-schema.json'); const Ajv = require('ajv'); const addFormats = require('ajv-formats'); const Fuse = require('fuse.js'); +const { languagesColor, technologiesColor } = require('./tags-color'); +const { categoryList } = require('./categorylist.js'); +const { createToolObject } = require('./tools-object'); +const schema = require('./tools-schema.json'); + const ajv = new Ajv(); addFormats(ajv, ['uri']); const validate = ajv.compile(schema); -let finalTools = {}; -for (var category of categoryList) { +const finalTools = {}; +for (const category of categoryList) { finalTools[category.name] = { description: category.description, - toolsList: [], + toolsList: [] }; } @@ -23,37 +24,35 @@ const options = { includeScore: true, shouldSort: true, threshold: 0.39, - keys: ['name', 'color', 'borderColor'], + keys: ['name', 'color', 'borderColor'] }; // Two seperate lists and Fuse objects initialised to search languages and technologies tags // from specified list of same. -let languageList = [...languagesColor], - technologyList = [...technologiesColor]; -let languageFuse = new Fuse(languageList, options), - technologyFuse = new Fuse(technologyList, options); +const languageList = [...languagesColor]; +const technologyList = [...technologiesColor]; +let languageFuse = new Fuse(languageList, options); +let technologyFuse = new Fuse(technologyList, options); // takes individual tool object and inserts borderColor and backgroundColor of the tags of // languages and technologies, for Tool Card in website. const getFinalTool = async (toolObject) => { - let finalObject = toolObject; + const finalObject = toolObject; - //there might be a tool without language + // there might be a tool without language if (toolObject.filters.language) { - let languageArray = []; + const languageArray = []; if (typeof toolObject.filters.language === 'string') { - const languageSearch = await languageFuse.search( - toolObject.filters.language, - ); + const languageSearch = await languageFuse.search(toolObject.filters.language); if (languageSearch.length) { languageArray.push(languageSearch[0].item); } else { // adds a new language object in the Fuse list as well as in tool object // so that it isn't missed out in the UI. - let languageObject = { + const languageObject = { name: toolObject.filters.language, color: 'bg-[#57f281]', - borderColor: 'border-[#37f069]', + borderColor: 'border-[#37f069]' }; languageList.push(languageObject); languageArray.push(languageObject); @@ -67,10 +66,10 @@ const getFinalTool = async (toolObject) => { } else { // adds a new language object in the Fuse list as well as in tool object // so that it isn't missed out in the UI. - let languageObject = { + const languageObject = { name: language, color: 'bg-[#57f281]', - borderColor: 'border-[#37f069]', + borderColor: 'border-[#37f069]' }; languageList.push(languageObject); languageArray.push(languageObject); @@ -80,7 +79,7 @@ const getFinalTool = async (toolObject) => { } finalObject.filters.language = languageArray; } - let technologyArray = []; + const technologyArray = []; if (toolObject.filters.technology) { for (const technology of toolObject?.filters?.technology) { const technologySearch = await technologyFuse.search(technology); @@ -89,10 +88,10 @@ const getFinalTool = async (toolObject) => { } else { // adds a new technology object in the Fuse list as well as in tool object // so that it isn't missed out in the UI. - let technologyObject = { + const technologyObject = { name: technology, color: 'bg-[#61d0f2]', - borderColor: 'border-[#40ccf7]', + borderColor: 'border-[#40ccf7]' }; technologyList.push(technologyObject); technologyArray.push(technologyObject); @@ -106,14 +105,9 @@ 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, - toolsPath, - tagsPath, -) => { +const combineTools = async (automatedTools, manualTools, toolsPath, tagsPath) => { for (const key in automatedTools) { - let finalToolsList = []; + const finalToolsList = []; if (automatedTools[key].toolsList.length) { for (const tool of automatedTools[key].toolsList) { finalToolsList.push(await getFinalTool(tool)); @@ -126,35 +120,23 @@ const combineTools = async ( if (isValid) { if (tool?.links?.repoUrl) { const url = new URL(tool.links.repoUrl); - isAsyncAPIrepo = url.href.startsWith( - 'https://github.com/asyncapi/', - ); + isAsyncAPIrepo = url.href.startsWith('https://github.com/asyncapi/'); } else isAsyncAPIrepo = false; - let toolObject = await createToolObject(tool, '', '', isAsyncAPIrepo); + const toolObject = await createToolObject(tool, '', '', isAsyncAPIrepo); finalToolsList.push(await getFinalTool(toolObject)); } else { - console.error( - 'Script is not failing, it is just dropping errors for further investigation', - ); + console.error('Script is not failing, it is just dropping errors for further investigation'); console.error(`Invalid ${tool.title} .asyncapi-tool file.`); console.error(`Located in manual-tools.json file`); - console.error( - 'Validation errors:', - JSON.stringify(validate.errors, null, 2), - ); + console.error('Validation errors:', JSON.stringify(validate.errors, null, 2)); } } } - finalToolsList.sort((tool, anotherTool) => - tool.title.localeCompare(anotherTool.title), - ); + finalToolsList.sort((tool, anotherTool) => tool.title.localeCompare(anotherTool.title)); finalTools[key].toolsList = finalToolsList; } fs.writeFileSync(toolsPath, JSON.stringify(finalTools)); - fs.writeFileSync( - tagsPath, - JSON.stringify({ languages: languageList, technologies: technologyList }), - ); + fs.writeFileSync(tagsPath, JSON.stringify({ languages: languageList, technologies: technologyList })); }; module.exports = { combineTools }; diff --git a/scripts/tools/extract-tools-github.js b/scripts/tools/extract-tools-github.js index 567a8077be4b..1db138a95add 100644 --- a/scripts/tools/extract-tools-github.js +++ b/scripts/tools/extract-tools-github.js @@ -3,15 +3,12 @@ require('dotenv').config(); const getData = async () => { try { - const result = await axios.get( - 'https://api.github.com/search/code?q=filename:.asyncapi-tool', - { - headers: { - accept: 'application/vnd.github.text-match+json', - authorization: `token ${process.env.GITHUB_TOKEN}`, - }, - }, - ); + const result = await axios.get('https://api.github.com/search/code?q=filename:.asyncapi-tool', { + headers: { + accept: 'application/vnd.github.text-match+json', + authorization: `token ${process.env.GITHUB_TOKEN}` + } + }); return result.data; } catch (err) { diff --git a/scripts/tools/tags-color.js b/scripts/tools/tags-color.js index 5897fcab5837..3483de2b0b08 100644 --- a/scripts/tools/tags-color.js +++ b/scripts/tools/tags-color.js @@ -3,176 +3,176 @@ const languagesColor = [ { name: 'Go/Golang', color: 'bg-[#8ECFDF]', - borderColor: 'border-[#00AFD9]', + borderColor: 'border-[#00AFD9]' }, { name: 'Java', color: 'bg-[#ECA2A4]', - borderColor: 'border-[#EC2125]', + borderColor: 'border-[#EC2125]' }, { name: 'JavaScript', color: 'bg-[#F2F1C7]', - borderColor: 'border-[#BFBE86]', + borderColor: 'border-[#BFBE86]' }, { name: 'HTML', color: 'bg-[#E2A291]', - borderColor: 'border-[#E44D26]', + borderColor: 'border-[#E44D26]' }, { name: 'C/C++', color: 'bg-[#93CDEF]', - borderColor: 'border-[#0080CC]', + borderColor: 'border-[#0080CC]' }, { name: 'C#', color: 'bg-[#E3AFE0]', - borderColor: 'border-[#9B4F96]', + borderColor: 'border-[#9B4F96]' }, { name: 'Python', color: 'bg-[#A8D0EF]', - borderColor: 'border-[#3878AB]', + borderColor: 'border-[#3878AB]' }, { name: 'TypeScript', color: 'bg-[#7DBCFE]', - borderColor: 'border-[#2C78C7]', + borderColor: 'border-[#2C78C7]' }, { name: 'Kotlin', color: 'bg-[#B1ACDF]', - borderColor: 'border-[#756BD9]', + borderColor: 'border-[#756BD9]' }, { name: 'Scala', color: 'bg-[#FFA299]', - borderColor: 'border-[#DF301F]', + borderColor: 'border-[#DF301F]' }, { name: 'Markdown', color: 'bg-[#BABEBF]', - borderColor: 'border-[#445B64]', + borderColor: 'border-[#445B64]' }, { name: 'YAML', color: 'bg-[#FFB764]', - borderColor: 'border-[#F1901F]', + borderColor: 'border-[#F1901F]' }, { name: 'R', color: 'bg-[#84B5ED]', - borderColor: 'border-[#246BBE]', + borderColor: 'border-[#246BBE]' }, { name: 'Ruby', color: 'bg-[#FF8289]', - borderColor: 'border-[#FF000F]', + borderColor: 'border-[#FF000F]' }, { name: 'Rust', color: 'bg-[#FFB8AA]', - borderColor: 'border-[#E43716]', + borderColor: 'border-[#E43716]' }, { name: 'Shell', color: 'bg-[#87D4FF]', - borderColor: 'border-[#389ED7]', + borderColor: 'border-[#389ED7]' }, { name: 'Groovy', color: 'bg-[#B6D5E5]', - borderColor: 'border-[#609DBC]', - }, + borderColor: 'border-[#609DBC]' + } ]; const technologiesColor = [ { name: 'Node.js', color: 'bg-[#BDFF67]', - borderColor: 'border-[#84CE24]', + borderColor: 'border-[#84CE24]' }, { name: 'Hermes', color: 'bg-[#8AEEBD]', - borderColor: 'border-[#2AB672]', + borderColor: 'border-[#2AB672]' }, { name: 'React JS', color: 'bg-[#9FECFA]', - borderColor: 'border-[#08D8FE]', + borderColor: 'border-[#08D8FE]' }, { name: '.NET', color: 'bg-[#A184FF]', - borderColor: 'border-[#5026D4]', + borderColor: 'border-[#5026D4]' }, { name: 'ASP.NET', color: 'bg-[#71C2FB]', - borderColor: 'border-[#1577BC]', + borderColor: 'border-[#1577BC]' }, { name: 'Springboot', color: 'bg-[#98E279]', - borderColor: 'border-[#68BC44]', + borderColor: 'border-[#68BC44]' }, { name: 'AWS', color: 'bg-[#FF9F59]', - borderColor: 'border-[#EF6703]', + borderColor: 'border-[#EF6703]' }, { name: 'Docker', color: 'bg-[#B8E0FF]', - borderColor: 'border-[#2596ED]', + borderColor: 'border-[#2596ED]' }, { name: 'Node-RED', color: 'bg-[#FF7474]', - borderColor: 'border-[#8F0101]', + borderColor: 'border-[#8F0101]' }, { name: 'Maven', color: 'bg-[#FF6B80]', - borderColor: 'border-[#CA1A33]', + borderColor: 'border-[#CA1A33]' }, { name: 'Saas', color: 'bg-[#6AB8EC]', - borderColor: 'border-[#2275AD]', + borderColor: 'border-[#2275AD]' }, { name: 'Kubernetes-native', color: 'bg-[#D7C7F2]', - borderColor: 'border-[#A387D2]', + borderColor: 'border-[#A387D2]' }, { name: 'Scala', color: 'bg-[#D7C7F2]', - borderColor: 'border-[#A387D2]', + borderColor: 'border-[#A387D2]' }, { name: 'Azure', color: 'bg-[#4B93FF]', - borderColor: 'border-[#015ADF]', + borderColor: 'border-[#015ADF]' }, { name: 'Jenkins', color: 'bg-[#D7C7F2]', - borderColor: 'border-[#A387D2]', + borderColor: 'border-[#A387D2]' }, { name: 'Flask', color: 'bg-[#D7C7F2]', - borderColor: 'border-[#A387D2]', + borderColor: 'border-[#A387D2]' }, { name: 'Nest Js', color: 'bg-[#E1224E]', - borderColor: 'border-[#B9012b]', - }, + borderColor: 'border-[#B9012b]' + } ]; module.exports = { languagesColor, technologiesColor }; diff --git a/scripts/tools/tools-object.js b/scripts/tools/tools-object.js index 9ef57e5cab31..57b152e49570 100644 --- a/scripts/tools/tools-object.js +++ b/scripts/tools/tools-object.js @@ -1,9 +1,10 @@ -const schema = require('./tools-schema.json'); const axios = require('axios'); const Ajv = require('ajv'); const addFormats = require('ajv-formats'); const Fuse = require('fuse.js'); +const schema = require('./tools-schema.json'); const { categoryList } = require('./categorylist'); + const ajv = new Ajv(); addFormats(ajv, ['uri']); const validate = ajv.compile(schema); @@ -14,7 +15,7 @@ const options = { includeScore: true, shouldSort: true, threshold: 0.4, - keys: ['tag'], + keys: ['tag'] }; const fuse = new Fuse(categoryList, options); @@ -24,28 +25,19 @@ const fuse = new Fuse(categoryList, options); // isAsyncAPIrepo boolean variable to define whether the tool repository is under // AsyncAPI organization or not, to create a JSON tool object as required in the frontend // side to show ToolCard. -const createToolObject = async ( - toolFile, - repositoryUrl = '', - repoDescription = '', - isAsyncAPIrepo = '', -) => { - let resultantObject = { +const createToolObject = async (toolFile, repositoryUrl = '', repoDescription = '', isAsyncAPIrepo = '') => { + const resultantObject = { title: toolFile.title, description: toolFile?.description ? toolFile.description : repoDescription, links: { ...toolFile.links, - repoUrl: toolFile?.links?.repoUrl - ? toolFile.links.repoUrl - : repositoryUrl, + repoUrl: toolFile?.links?.repoUrl ? toolFile.links.repoUrl : repositoryUrl }, filters: { ...toolFile.filters, - hasCommercial: toolFile?.filters?.hasCommercial - ? toolFile.filters.hasCommercial - : false, - isAsyncAPIOwner: isAsyncAPIrepo, - }, + hasCommercial: toolFile?.filters?.hasCommercial ? toolFile.filters.hasCommercial : false, + isAsyncAPIOwner: isAsyncAPIrepo + } }; return resultantObject; }; @@ -55,43 +47,43 @@ const createToolObject = async ( // and creating a JSON tool object in which all the tools are listed in defined // categories order, which is then updated in `automated-tools.json` file. async function convertTools(data) { - let finalToolsObject = {}; + const finalToolsObject = {}; const dataArray = data.items; // initialising finalToolsObject with all categories inside it with proper elements in each category - for (var index in categoryList) { + for (const index in categoryList) { finalToolsObject[categoryList[index].name] = { description: categoryList[index].description, - toolsList: [], + toolsList: [] }; } - for (let tool of dataArray) { + for (const tool of dataArray) { try { if (tool.name.startsWith('.asyncapi-tool')) { // extracting the reference id of the repository which will be used to extract the path of the .asyncapi-tool file in the Tools repository // ex: for a url = "https://api.github.com/repositories/351453552/contents/.asyncapi-tool?ref=61855e7365a881e98c2fe667a658a0005753d873" // the text (id) present after '=' gives us a reference id for the repo - let reference_id = tool.url.split('=')[1]; - let download_url = `https://raw.githubusercontent.com/${tool.repository.full_name}/${reference_id}/${tool.path}`; + const reference_id = tool.url.split('=')[1]; + const download_url = `https://raw.githubusercontent.com/${tool.repository.full_name}/${reference_id}/${tool.path}`; const { data: toolFileContent } = await axios.get(download_url); - //some stuff can be YAML + // some stuff can be YAML const jsonToolFileContent = await convertToJson(toolFileContent); - //validating against JSON Schema for tools file + // validating against JSON Schema for tools file const isValid = await validate(jsonToolFileContent); if (isValid) { - let repositoryUrl = tool.repository.html_url; - let repoDescription = tool.repository.description; - let isAsyncAPIrepo = tool.repository.owner.login === 'asyncapi'; - let toolObject = await createToolObject( + const repositoryUrl = tool.repository.html_url; + const repoDescription = tool.repository.description; + const isAsyncAPIrepo = tool.repository.owner.login === 'asyncapi'; + const toolObject = await createToolObject( jsonToolFileContent, repositoryUrl, repoDescription, - isAsyncAPIrepo, + isAsyncAPIrepo ); // Tool Object is appended to each category array according to Fuse search for categories inside Tool Object @@ -99,35 +91,20 @@ async function convertTools(data) { const categorySearch = await fuse.search(category); if (categorySearch.length) { - let searchedCategoryName = categorySearch[0].item.name; - if ( - !finalToolsObject[searchedCategoryName].toolsList.find( - (element) => element === toolObject, - ) - ) - finalToolsObject[searchedCategoryName].toolsList.push( - toolObject, - ); + const searchedCategoryName = categorySearch[0].item.name; + if (!finalToolsObject[searchedCategoryName].toolsList.find((element) => element === toolObject)) + finalToolsObject[searchedCategoryName].toolsList.push(toolObject); } else { // if Tool object has a category, not defined in our categorylist, then this provides a `other` category to the tool. - if ( - !finalToolsObject['Others'].toolsList.find( - (element) => element === toolObject, - ) - ) - finalToolsObject['Others'].toolsList.push(toolObject); + if (!finalToolsObject.Others.toolsList.find((element) => element === toolObject)) + finalToolsObject.Others.toolsList.push(toolObject); } }); } else { - console.error( - 'Script is not failing, it is just dropping errors for further investigation', - ); + console.error('Script is not failing, it is just dropping errors for further investigation'); console.error('Invalid .asyncapi-tool file.'); console.error(`Located in: ${tool.html_url}`); - console.error( - 'Validation errors:', - JSON.stringify(validate.errors, null, 2), - ); + console.error('Validation errors:', JSON.stringify(validate.errors, null, 2)); } } } catch (err) { diff --git a/scripts/utils.js b/scripts/utils.js index 66d01b75afc7..fa893a6de22e 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -18,9 +18,7 @@ function convertToJson(contentYAMLorJSON) { return yamlContent; } catch (yamlError) { // If parsing as YAML also fails, throw an error - throw new Error( - `Invalid content format:\nJSON Parse Error: ${jsonError}\nYAML Parse Error: ${yamlError}`, - ); + throw new Error(`Invalid content format:\nJSON Parse Error: ${jsonError}\nYAML Parse Error: ${yamlError}`); } } } diff --git a/scripts/utils/readAndWriteJson.js b/scripts/utils/readAndWriteJson.js index d1ed2dd43a12..e3e2a6f2b6e3 100644 --- a/scripts/utils/readAndWriteJson.js +++ b/scripts/utils/readAndWriteJson.js @@ -1,5 +1,5 @@ const { - promises: { readFile, writeFile }, + promises: { readFile, writeFile } } = require('fs'); const { convertToJson } = require('../utils'); From ad8c426af27358a639ace24bf8090e653559027c Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Mon, 18 Nov 2024 11:20:49 +0530 Subject: [PATCH 03/59] migrate build-pages --- scripts/{build-pages.js => build-pages.ts} | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) rename scripts/{build-pages.js => build-pages.ts} (88%) diff --git a/scripts/build-pages.js b/scripts/build-pages.ts similarity index 88% rename from scripts/build-pages.js rename to scripts/build-pages.ts index 287d44f046b0..ed6eda670f98 100644 --- a/scripts/build-pages.js +++ b/scripts/build-pages.ts @@ -1,5 +1,5 @@ -const fs = require('fs'); -const path = require('path'); +import fs from 'fs'; +import path from 'path'; const SRC_DIR = 'markdown'; const TARGET_DIR = 'pages'; @@ -11,7 +11,7 @@ if (!fs.existsSync(TARGET_DIR)) { fs.mkdirSync(TARGET_DIR, { recursive: true }); } -function capitalizeJsxTags(content) { +export function capitalizeJsxTags(content: string) { return content.replace(/<\/?(\w+)/g, function (match, letter) { if (capitalizeTags.includes(letter.toLowerCase())) { return `<${match[1] === '/' ? '/' : ''}${letter[0].toUpperCase()}${letter.slice(1)}`; @@ -20,7 +20,7 @@ function capitalizeJsxTags(content) { }); } -function copyAndRenameFiles(srcDir, targetDir) { +export function copyAndRenameFiles(srcDir: string, targetDir: string) { // Read all files and directories from source directory const entries = fs.readdirSync(srcDir, { withFileTypes: true }); @@ -56,5 +56,3 @@ function copyAndRenameFiles(srcDir, targetDir) { } copyAndRenameFiles(SRC_DIR, TARGET_DIR); - -module.exports = { copyAndRenameFiles, capitalizeJsxTags }; From eedff42e93e4d1254b71f02106bdeccf8a35d939 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Mon, 18 Nov 2024 11:21:38 +0530 Subject: [PATCH 04/59] add ts-node configuration --- package-lock.json | 158 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 6 +- 2 files changed, 161 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0749d409a5fc..82a8b0119b9b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -122,7 +122,8 @@ "remark-cli": "^12.0.1", "remark-lint": "^10.0.0", "remark-mdx": "^3.0.1", - "storybook": "^8.2.4" + "storybook": "^8.2.4", + "ts-node": "^10.9.2" } }, "node_modules/@adobe/css-tools": { @@ -2413,6 +2414,28 @@ "yarn": ">=1.22.18" } }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "devOptional": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "devOptional": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@docsearch/css": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/@docsearch/css/-/css-3.6.0.tgz", @@ -7172,6 +7195,30 @@ "node": ">=10.13.0" } }, + "node_modules/@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "devOptional": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "devOptional": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "devOptional": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "devOptional": true + }, "node_modules/@types/acorn": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/@types/acorn/-/acorn-4.0.6.tgz", @@ -10726,6 +10773,12 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "devOptional": true + }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -18242,6 +18295,12 @@ "semver": "bin/semver.js" } }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "devOptional": true + }, "node_modules/makeerror": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", @@ -28606,6 +28665,88 @@ "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==" }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "devOptional": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/acorn": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", + "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", + "devOptional": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ts-node/node_modules/acorn-walk": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", + "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", + "devOptional": true, + "dependencies": { + "acorn": "^8.11.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ts-node/node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "devOptional": true + }, + "node_modules/ts-node/node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "devOptional": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/ts-pnp": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/ts-pnp/-/ts-pnp-1.2.0.tgz", @@ -29708,6 +29849,12 @@ "node": ">=6" } }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "devOptional": true + }, "node_modules/v8-to-istanbul": { "version": "9.3.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", @@ -30450,6 +30597,15 @@ "node": ">=12" } }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "devOptional": true, + "engines": { + "node": ">=6" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index 84f538697d4d..13ce5e81207a 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,12 @@ "version": "0.1.0", "description": "AsyncAPI website", "private": true, + "type": "module", "scripts": { "dev": "npm run build-scripts && next dev", "build": "npm run build-scripts && next build", "test": "jest --passWithNoTests", - "build:pages": "node scripts/build-pages.js && npm run format:mdx", + "build:pages": "node --loader ts-node/esm scripts/build-pages.ts && npm run format:mdx", "build:posts": "node scripts/index.js", "build-scripts": "npm run build:pages && npm run lint:mdx && npm run build:posts", "write:blog": "node ./scripts/compose.js", @@ -151,6 +152,7 @@ "eslint-plugin-storybook": "^0.8.0", "eslint-plugin-tailwindcss": "^3.14.2", "eslint-plugin-unused-imports": "^3.1.0", + "fast-xml-parser": "^4.5.0", "inquirer": "^9.2.14", "jest": "^29.7.0", "postcss-import": "^16.0.1", @@ -158,6 +160,6 @@ "remark-lint": "^10.0.0", "remark-mdx": "^3.0.1", "storybook": "^8.2.4", - "fast-xml-parser": "^4.5.0" + "ts-node": "^10.9.2" } } From df75c79b377679c3c41f0e23a41b750ca897723f Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Mon, 18 Nov 2024 11:21:53 +0530 Subject: [PATCH 05/59] setup eslint rule to ignore js-doc in script files --- .eslintrc | 178 +++++++++++++++++++++--------------------------------- 1 file changed, 70 insertions(+), 108 deletions(-) diff --git a/.eslintrc b/.eslintrc index f77da8144e9c..69b1b9e34900 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,18 +4,15 @@ "next/core-web-vitals", "eslint:recommended", "plugin:prettier/recommended", - "plugin:storybook/recommended" + "plugin:storybook/recommended", ], "env": { "browser": true, "es2021": true, "node": true, - "jest": true + "jest": true, }, - "plugins": [ - "react", - "jsx-a11y" - ], + "plugins": ["react", "jsx-a11y"], "rules": { "prettier/prettier": [ "error", @@ -33,47 +30,43 @@ "insertPragma": false, "requirePragma": false, "jsxSingleQuote": true, - "printWidth": 120 - } + "printWidth": 120, + }, ], "max-len": [ "error", { "code": 120, "ignoreUrls": true, - "ignorePattern": "(className=\\{[\\s\\S]*\\}|.*\\}|'.*'|className='.*')" // Ignore classnames - } - ] + "ignorePattern": "(className=\\{[\\s\\S]*\\}|.*\\}|'.*'|className='.*')", // Ignore classnames + }, + ], }, "globals": { "React": true, "expect": true, "jsdom": true, - "JSX": true + "JSX": true, }, "overrides": [ // Configuration for TypeScript files { - "files": [ - "**/*.ts", - "**/*.tsx", - "netlify/*.ts" - ], + "files": ["**/*.ts", "**/*.tsx", "netlify/*.ts"], "plugins": [ "@typescript-eslint", "tailwindcss", "unused-imports", - "simple-import-sort" + "simple-import-sort", ], "extends": [ "plugin:tailwindcss/recommended", "airbnb-typescript", "next/core-web-vitals", "plugin:prettier/recommended", - "plugin:storybook/recommended" + "plugin:storybook/recommended", ], "parserOptions": { - "project": "./tsconfig.json" + "project": "./tsconfig.json", }, "rules": { "react/destructuring-assignment": "off", // Vscode doesn't support automatically destructuring, it's a pain to add a new variable @@ -89,7 +82,7 @@ "error", "ForInStatement", "LabeledStatement", - "WithStatement" + "WithStatement", ], // Overrides Airbnb configuration and enable no-restricted-syntax "import/prefer-default-export": "off", // Named export is easier to refactor automatically "tailwindcss/no-custom-classname": "off", // Disabled otherwise nightmare to allow each custom tailwind classes @@ -101,8 +94,8 @@ "unused-imports/no-unused-vars": [ "error", { - "argsIgnorePattern": "^_" - } + "argsIgnorePattern": "^_", + }, ], // Variables "init-declarations": "off", @@ -126,42 +119,30 @@ "off", "stroustrup", { - "allowSingleLine": true - } + "allowSingleLine": true, + }, ], "camelcase": "off", "capitalized-comments": "off", - "comma-dangle": [ - "error", - "never" - ], + "comma-dangle": ["error", "never"], "comma-spacing": [ 2, { "before": false, - "after": true - } - ], - "comma-style": [ - "error", - "last" + "after": true, + }, ], + "comma-style": ["error", "last"], "eol-last": "error", "func-call-spacing": "error", "func-name-matching": "error", "func-names": "off", "func-style": "off", - "jsx-quotes": [ - "error", - "prefer-single" - ], + "jsx-quotes": ["error", "prefer-single"], "key-spacing": "error", "keyword-spacing": "error", "line-comment-position": "off", - "linebreak-style": [ - "error", - "unix" - ], + "linebreak-style": ["error", "unix"], "lines-around-comment": [ "error", { @@ -174,22 +155,22 @@ "allowObjectStart": true, "allowObjectEnd": false, "allowArrayStart": true, - "allowArrayEnd": false - } + "allowArrayEnd": false, + }, ], "max-depth": "error", "max-lines": [ "error", { - "max": 2000 - } + "max": 2000, + }, ], "max-nested-callbacks": "error", "max-statements-per-line": [ "error", { - "max": 2 - } + "max": 2, + }, ], "multiline-comment-style": "off", "multiline-ternary": "off", @@ -198,13 +179,10 @@ "newline-per-chained-call": [ "error", { - "ignoreChainWithDepth": 4 - } - ], - "newline-after-var": [ - "error", - "always" + "ignoreChainWithDepth": 4, + }, ], + "newline-after-var": ["error", "always"], "no-array-constructor": "error", "no-lonely-if": "error", "no-mixed-operators": "off", @@ -213,8 +191,8 @@ "no-multiple-empty-lines": [ "error", { - "max": 1 - } + "max": 1, + }, ], "no-negated-condition": "error", "no-nested-ternary": "error", @@ -227,63 +205,51 @@ "no-whitespace-before-property": "error", "nonblock-statement-body-position": "error", "object-curly-newline": "off", - "object-curly-spacing": [ - "error", - "always" - ], + "object-curly-spacing": ["error", "always"], "object-property-newline": "off", - "padded-blocks": [ - "error", - "never" - ], + "padded-blocks": ["error", "never"], "padding-line-between-statements": [ "error", { "blankLine": "always", "prev": "*", - "next": "return" + "next": "return", }, { "blankLine": "always", - "prev": [ - "const", - "let", - "var" - ], - "next": "*" + "prev": ["const", "let", "var"], + "next": "*", }, { "blankLine": "any", - "prev": [ - "const", - "let", - "var" - ], - "next": [ - "const", - "let", - "var" - ] - } - ], - "quote-props": [ - "error", - "as-needed" + "prev": ["const", "let", "var"], + "next": ["const", "let", "var"], + }, ], + "quote-props": ["error", "as-needed"], "quotes": [ "error", "single", { - "avoidEscape": true - } + "avoidEscape": true, + }, + ], + "require-jsdoc": [ + "warn", + { + "overrides": [ + { + "files": ["path/to/your/folder/**"], + "rules": { + "require-jsdoc": "off", + }, + }, + ], + }, ], - "require-jsdoc": "warn", "semi": "error", "semi-spacing": "error", - "semi-style": [ - "error", - "last" - ], + "semi-style": ["error", "last"], "sort-keys": "off", "sort-vars": "off", "space-before-blocks": "error", @@ -296,22 +262,18 @@ "always", { "block": { - "exceptions": [ - "!" - ] - } - } + "exceptions": ["!"], + }, + }, ], - "switch-colon-spacing": "error" - } + "switch-colon-spacing": "error", + }, }, { - "files": [ - "components/logos/*" - ], + "files": ["components/logos/*"], "rules": { - "max-len": "off" - } - } - ] + "max-len": "off", + }, + }, + ], } From 7bf568a00840f54350e023b6b7e7bc376e7f72ce Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Mon, 18 Nov 2024 11:23:24 +0530 Subject: [PATCH 06/59] Revert "setup eslint rule to ignore js-doc in script files" This reverts commit df75c79b377679c3c41f0e23a41b750ca897723f. --- .eslintrc | 178 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 108 insertions(+), 70 deletions(-) diff --git a/.eslintrc b/.eslintrc index 69b1b9e34900..f77da8144e9c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,15 +4,18 @@ "next/core-web-vitals", "eslint:recommended", "plugin:prettier/recommended", - "plugin:storybook/recommended", + "plugin:storybook/recommended" ], "env": { "browser": true, "es2021": true, "node": true, - "jest": true, + "jest": true }, - "plugins": ["react", "jsx-a11y"], + "plugins": [ + "react", + "jsx-a11y" + ], "rules": { "prettier/prettier": [ "error", @@ -30,43 +33,47 @@ "insertPragma": false, "requirePragma": false, "jsxSingleQuote": true, - "printWidth": 120, - }, + "printWidth": 120 + } ], "max-len": [ "error", { "code": 120, "ignoreUrls": true, - "ignorePattern": "(className=\\{[\\s\\S]*\\}|.*\\}|'.*'|className='.*')", // Ignore classnames - }, - ], + "ignorePattern": "(className=\\{[\\s\\S]*\\}|.*\\}|'.*'|className='.*')" // Ignore classnames + } + ] }, "globals": { "React": true, "expect": true, "jsdom": true, - "JSX": true, + "JSX": true }, "overrides": [ // Configuration for TypeScript files { - "files": ["**/*.ts", "**/*.tsx", "netlify/*.ts"], + "files": [ + "**/*.ts", + "**/*.tsx", + "netlify/*.ts" + ], "plugins": [ "@typescript-eslint", "tailwindcss", "unused-imports", - "simple-import-sort", + "simple-import-sort" ], "extends": [ "plugin:tailwindcss/recommended", "airbnb-typescript", "next/core-web-vitals", "plugin:prettier/recommended", - "plugin:storybook/recommended", + "plugin:storybook/recommended" ], "parserOptions": { - "project": "./tsconfig.json", + "project": "./tsconfig.json" }, "rules": { "react/destructuring-assignment": "off", // Vscode doesn't support automatically destructuring, it's a pain to add a new variable @@ -82,7 +89,7 @@ "error", "ForInStatement", "LabeledStatement", - "WithStatement", + "WithStatement" ], // Overrides Airbnb configuration and enable no-restricted-syntax "import/prefer-default-export": "off", // Named export is easier to refactor automatically "tailwindcss/no-custom-classname": "off", // Disabled otherwise nightmare to allow each custom tailwind classes @@ -94,8 +101,8 @@ "unused-imports/no-unused-vars": [ "error", { - "argsIgnorePattern": "^_", - }, + "argsIgnorePattern": "^_" + } ], // Variables "init-declarations": "off", @@ -119,30 +126,42 @@ "off", "stroustrup", { - "allowSingleLine": true, - }, + "allowSingleLine": true + } ], "camelcase": "off", "capitalized-comments": "off", - "comma-dangle": ["error", "never"], + "comma-dangle": [ + "error", + "never" + ], "comma-spacing": [ 2, { "before": false, - "after": true, - }, + "after": true + } + ], + "comma-style": [ + "error", + "last" ], - "comma-style": ["error", "last"], "eol-last": "error", "func-call-spacing": "error", "func-name-matching": "error", "func-names": "off", "func-style": "off", - "jsx-quotes": ["error", "prefer-single"], + "jsx-quotes": [ + "error", + "prefer-single" + ], "key-spacing": "error", "keyword-spacing": "error", "line-comment-position": "off", - "linebreak-style": ["error", "unix"], + "linebreak-style": [ + "error", + "unix" + ], "lines-around-comment": [ "error", { @@ -155,22 +174,22 @@ "allowObjectStart": true, "allowObjectEnd": false, "allowArrayStart": true, - "allowArrayEnd": false, - }, + "allowArrayEnd": false + } ], "max-depth": "error", "max-lines": [ "error", { - "max": 2000, - }, + "max": 2000 + } ], "max-nested-callbacks": "error", "max-statements-per-line": [ "error", { - "max": 2, - }, + "max": 2 + } ], "multiline-comment-style": "off", "multiline-ternary": "off", @@ -179,10 +198,13 @@ "newline-per-chained-call": [ "error", { - "ignoreChainWithDepth": 4, - }, + "ignoreChainWithDepth": 4 + } + ], + "newline-after-var": [ + "error", + "always" ], - "newline-after-var": ["error", "always"], "no-array-constructor": "error", "no-lonely-if": "error", "no-mixed-operators": "off", @@ -191,8 +213,8 @@ "no-multiple-empty-lines": [ "error", { - "max": 1, - }, + "max": 1 + } ], "no-negated-condition": "error", "no-nested-ternary": "error", @@ -205,51 +227,63 @@ "no-whitespace-before-property": "error", "nonblock-statement-body-position": "error", "object-curly-newline": "off", - "object-curly-spacing": ["error", "always"], + "object-curly-spacing": [ + "error", + "always" + ], "object-property-newline": "off", - "padded-blocks": ["error", "never"], + "padded-blocks": [ + "error", + "never" + ], "padding-line-between-statements": [ "error", { "blankLine": "always", "prev": "*", - "next": "return", + "next": "return" }, { "blankLine": "always", - "prev": ["const", "let", "var"], - "next": "*", + "prev": [ + "const", + "let", + "var" + ], + "next": "*" }, { "blankLine": "any", - "prev": ["const", "let", "var"], - "next": ["const", "let", "var"], - }, + "prev": [ + "const", + "let", + "var" + ], + "next": [ + "const", + "let", + "var" + ] + } + ], + "quote-props": [ + "error", + "as-needed" ], - "quote-props": ["error", "as-needed"], "quotes": [ "error", "single", { - "avoidEscape": true, - }, - ], - "require-jsdoc": [ - "warn", - { - "overrides": [ - { - "files": ["path/to/your/folder/**"], - "rules": { - "require-jsdoc": "off", - }, - }, - ], - }, + "avoidEscape": true + } ], + "require-jsdoc": "warn", "semi": "error", "semi-spacing": "error", - "semi-style": ["error", "last"], + "semi-style": [ + "error", + "last" + ], "sort-keys": "off", "sort-vars": "off", "space-before-blocks": "error", @@ -262,18 +296,22 @@ "always", { "block": { - "exceptions": ["!"], - }, - }, + "exceptions": [ + "!" + ] + } + } ], - "switch-colon-spacing": "error", - }, + "switch-colon-spacing": "error" + } }, { - "files": ["components/logos/*"], + "files": [ + "components/logos/*" + ], "rules": { - "max-len": "off", - }, - }, - ], + "max-len": "off" + } + } + ] } From 4c51a800a41ad4ae45d95d79c2c24a7557c25106 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 00:29:57 +0530 Subject: [PATCH 07/59] move to imports --- next-i18next.config.js | 20 +++++------ pages/_document.tsx | 46 +++++++++++++++++++------ postcss.config.js => postcss.config.cjs | 0 scripts/adopters/index.js | 11 +++--- scripts/build-docs.js | 6 ++-- scripts/build-meetings.js | 8 ++--- scripts/build-newsroom-videos.js | 8 ++--- scripts/build-post-list.js | 26 ++++++++------ scripts/build-rss.js | 11 +++--- scripts/build-tools.js | 12 +++---- scripts/casestudies/index.js | 8 ++--- scripts/compose.js | 8 ++--- scripts/dashboard/build-dashboard.js | 10 +++--- scripts/dashboard/issue-queries.js | 2 +- scripts/finance/index.js | 12 +++---- scripts/index.js | 19 +++++----- scripts/markdown/check-markdown.js | 6 ++-- scripts/tools/categorylist.js | 2 +- scripts/tools/combine-tools.js | 18 +++++----- scripts/tools/extract-tools-github.js | 5 +-- scripts/tools/tags-color.js | 2 +- scripts/tools/tools-object.js | 16 ++++----- scripts/utils.js | 4 +-- scripts/utils/readAndWriteJson.js | 10 +++--- utils/getStatic.ts | 12 +++---- utils/languageDetector.ts | 4 +-- 26 files changed, 161 insertions(+), 125 deletions(-) rename postcss.config.js => postcss.config.cjs (100%) diff --git a/next-i18next.config.js b/next-i18next.config.js index 2848266d6554..854dbe88c0ac 100644 --- a/next-i18next.config.js +++ b/next-i18next.config.js @@ -1,10 +1,10 @@ -module.exports = { - i18n: { - locales: ['en', 'de'], - defaultLocale : 'en', - namespaces: ['landing-page', 'common', 'tools'], - defaultNamespace: 'landing-page', - react: { useSuspense: false },// this line - }, - - }; +const config = { + i18n: { + locales: ['en', 'de'], + defaultLocale: 'en', + namespaces: ['landing-page', 'common', 'tools'], + defaultNamespace: 'landing-page', + react: { useSuspense: false } // this line + } +}; +export default config; diff --git a/pages/_document.tsx b/pages/_document.tsx index b220a1b44841..b71582a10850 100644 --- a/pages/_document.tsx +++ b/pages/_document.tsx @@ -1,7 +1,7 @@ import Document, { Head, Html, Main, NextScript } from 'next/document'; import React from 'react'; -import i18nextConfig from '../next-i18next.config'; +import i18nextConfig from '../next-i18next.config.js'; class MyDocument extends Document { static async getInitialProps(ctx: any) { @@ -12,27 +12,51 @@ class MyDocument extends Document { render() { // eslint-disable-next-line no-underscore-dangle - const currentLocale = this.props.__NEXT_DATA__.query.locale || i18nextConfig.i18n.defaultLocale; + const currentLocale = + this.props.__NEXT_DATA__.query.locale || i18nextConfig.i18n.defaultLocale; return ( {/* Load Work Sans font */} - - + + {/* eslint-disable-next-line max-len */} {/* Icons */} - - - - + + + + - +
diff --git a/postcss.config.js b/postcss.config.cjs similarity index 100% rename from postcss.config.js rename to postcss.config.cjs diff --git a/scripts/adopters/index.js b/scripts/adopters/index.js index a8c8363d25ab..9018b80054ac 100644 --- a/scripts/adopters/index.js +++ b/scripts/adopters/index.js @@ -1,6 +1,9 @@ -const { resolve } = require('path'); -const writeJSON = require('../utils/readAndWriteJson.js'); +import { resolve, dirname } from 'path'; +import { fileURLToPath } from 'url'; +import { writeJSON } from '../utils/readAndWriteJson.js'; -module.exports = async function buildAdoptersList() { +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); +export async function buildAdoptersList() { writeJSON('config/adopters.yml', resolve(__dirname, '../../config', 'adopters.json')); -}; +} diff --git a/scripts/build-docs.js b/scripts/build-docs.js index 48693f176ba8..b0183e13cf7b 100644 --- a/scripts/build-docs.js +++ b/scripts/build-docs.js @@ -1,4 +1,6 @@ -const sortBy = require('lodash/sortBy'); +import lodash from 'lodash'; + +const { sortBy } = lodash; function buildNavTree(navItems) { try { @@ -187,4 +189,4 @@ function addDocButtons(docPosts, treePosts) { return structuredPosts; } -module.exports = { buildNavTree, addDocButtons, convertDocPosts }; +export { buildNavTree, addDocButtons, convertDocPosts }; diff --git a/scripts/build-meetings.js b/scripts/build-meetings.js index ac556b7578d4..4a76d021e853 100644 --- a/scripts/build-meetings.js +++ b/scripts/build-meetings.js @@ -1,6 +1,6 @@ -const { writeFileSync } = require('fs'); -const { resolve } = require('path'); -const { google } = require('googleapis'); +import { writeFileSync } from 'fs'; +import { resolve } from 'path'; +import { google } from 'googleapis'; async function buildMeetings(writePath) { let auth; @@ -57,4 +57,4 @@ if (require.main === module) { buildMeetings(resolve(__dirname, '../config', 'meetings.json')); } -module.exports = { buildMeetings }; +export { buildMeetings }; diff --git a/scripts/build-newsroom-videos.js b/scripts/build-newsroom-videos.js index 40ad1617362e..7cd4917c7199 100644 --- a/scripts/build-newsroom-videos.js +++ b/scripts/build-newsroom-videos.js @@ -1,6 +1,6 @@ -const { writeFileSync } = require('fs-extra'); -const { resolve } = require('path'); -const fetch = require('node-fetch-2'); +import { writeFileSync } from 'fs'; +import { resolve } from 'path'; +import fetch from 'node-fetch'; async function buildNewsroomVideos(writePath) { try { @@ -50,4 +50,4 @@ if (require.main === module) { buildNewsroomVideos(resolve(__dirname, '../config', 'newsroom_videos.json')); } -module.exports = { buildNewsroomVideos }; +export { buildNewsroomVideos }; diff --git a/scripts/build-post-list.js b/scripts/build-post-list.js index 3cfee35032ec..946cc6456166 100644 --- a/scripts/build-post-list.js +++ b/scripts/build-post-list.js @@ -1,11 +1,17 @@ -const { readdirSync, statSync, existsSync, readFileSync, writeFileSync } = require('fs'); -const { resolve, basename } = require('path'); -const frontMatter = require('gray-matter'); -const toc = require('markdown-toc'); -const { slugify } = require('markdown-toc/lib/utils'); -const readingTime = require('reading-time'); -const { markdownToTxt } = require('markdown-to-txt'); -const { buildNavTree, addDocButtons } = require('./build-docs'); +import { readFileSync, writeFileSync, readdirSync, statSync, existsSync } from 'fs'; +import { resolve, basename, dirname } from 'path'; +import frontMatter from 'gray-matter'; +import toc from 'markdown-toc'; +import markdownTocUtils from 'markdown-toc/lib/utils.js'; +import readingTime from 'reading-time'; +import { markdownToTxt } from 'markdown-to-txt'; +import { fileURLToPath } from 'url'; +import { buildNavTree, addDocButtons } from './build-docs.js'; + +const { slugify } = markdownTocUtils; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); let specWeight = 100; const result = { @@ -31,7 +37,7 @@ const addItem = (details) => { } }; -module.exports = async function buildPostList() { +export async function buildPostList() { walkDirectories(postDirectories, result); const treePosts = buildNavTree(result.docs.filter((p) => p.slug.startsWith('/docs/'))); result.docsTree = treePosts; @@ -40,7 +46,7 @@ module.exports = async function buildPostList() { // console.log(inspect(result, { depth: null, colors: true })) } writeFileSync(resolve(__dirname, '..', 'config', 'posts.json'), JSON.stringify(result, null, ' ')); -}; +} function walkDirectories(directories, result, sectionWeight = 0, sectionTitle, sectionId, rootSectionId) { for (const dir of directories) { diff --git a/scripts/build-rss.js b/scripts/build-rss.js index 75195ea53ccf..bda4c61664cc 100644 --- a/scripts/build-rss.js +++ b/scripts/build-rss.js @@ -1,8 +1,9 @@ -const fs = require('fs').promises; -const json2xml = require('jgexml/json2xml'); +import fs from 'fs/promises'; +import json2xml from 'jgexml/json2xml.js'; +import posts from '../config/posts.json' assert { type: 'json' }; function getAllPosts() { - return require('../config/posts.json'); + return posts; } function clean(s) { @@ -15,7 +16,7 @@ function clean(s) { return s; } -module.exports = async function rssFeed(type, title, desc, outputPath) { +export async function rssFeed(type, title, desc, outputPath) { try { let posts = getAllPosts()[`${type}`]; const missingDatePosts = posts.filter((post) => !post.date); @@ -97,4 +98,4 @@ module.exports = async function rssFeed(type, title, desc, outputPath) { } catch (err) { throw new Error(`Failed to generate RSS feed: ${err.message}`); } -}; +} diff --git a/scripts/build-tools.js b/scripts/build-tools.js index 83db76534f11..47e0d806faa7 100644 --- a/scripts/build-tools.js +++ b/scripts/build-tools.js @@ -1,8 +1,8 @@ -const fs = require('fs-extra'); -const { resolve } = require('path'); -const { getData } = require('./tools/extract-tools-github'); -const { convertTools } = require('./tools/tools-object'); -const { combineTools } = require('./tools/combine-tools'); +import fs from 'fs-extra'; +import { resolve } from 'path'; +import { getData } from './tools/extract-tools-github.js'; +import { convertTools } from './tools/tools-object.js'; +import { combineTools } from './tools/combine-tools.js'; const buildTools = async (automatedToolsPath, manualToolsPath, toolsPath, tagsPath) => { try { @@ -27,4 +27,4 @@ if (require.main === module) { buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); } -module.exports = { buildTools }; +export { buildTools }; diff --git a/scripts/casestudies/index.js b/scripts/casestudies/index.js index 22011781f1be..8e5ed249288c 100644 --- a/scripts/casestudies/index.js +++ b/scripts/casestudies/index.js @@ -1,7 +1,7 @@ -const { readdir, writeFile, readFile } = require('fs').promises; -const { convertToJson } = require('../utils'); +import { readdir, writeFile, readFile } from 'fs/promises'; +import { convertToJson } from '../utils.js'; -module.exports = async function buildCaseStudiesList(dirWithCaseStudy, writeFilePath) { +export async function buildCaseStudiesList(dirWithCaseStudy, writeFilePath) { try { const files = await readdir(dirWithCaseStudy); const caseStudiesList = []; @@ -16,4 +16,4 @@ module.exports = async function buildCaseStudiesList(dirWithCaseStudy, writeFile } catch (err) { throw new Error(err); } -}; +} diff --git a/scripts/compose.js b/scripts/compose.js index 18d8d724420d..63c653554b20 100644 --- a/scripts/compose.js +++ b/scripts/compose.js @@ -2,10 +2,10 @@ * Script based on https://github.com/timlrx/tailwind-nextjs-starter-blog/blob/master/scripts/compose.js */ -const fs = require('fs'); -const inquirer = require('inquirer'); -const dedent = require('dedent'); -const moment = require('moment'); +import fs from 'fs'; +import inquirer from 'inquirer'; +import dedent from 'dedent'; +import moment from 'moment'; const genFrontMatter = (answers) => { const d = new Date(); diff --git a/scripts/dashboard/build-dashboard.js b/scripts/dashboard/build-dashboard.js index 00e2049a6338..07489c2eae59 100644 --- a/scripts/dashboard/build-dashboard.js +++ b/scripts/dashboard/build-dashboard.js @@ -1,7 +1,7 @@ -const { writeFile } = require('fs-extra'); -const { resolve } = require('path'); -const { graphql } = require('@octokit/graphql'); -const { Queries } = require('./issue-queries'); +import { writeFile } from 'fs-extra'; +import { resolve } from 'path'; +import { graphql } from '@octokit/graphql'; +import { Queries } from './issue-queries'; /** * Introduces a delay in the execution flow. @@ -181,7 +181,7 @@ if (require.main === module) { start(resolve(__dirname, '..', '..', 'dashboard.json')); } -module.exports = { +export { getLabel, monthsSince, mapGoodFirstIssues, diff --git a/scripts/dashboard/issue-queries.js b/scripts/dashboard/issue-queries.js index 4b2e5a87853c..7eafae9fbd3a 100644 --- a/scripts/dashboard/issue-queries.js +++ b/scripts/dashboard/issue-queries.js @@ -1,4 +1,4 @@ -exports.Queries = Object.freeze({ +export const Queries = Object.freeze({ pullRequestById: ` query IssueByID($id: ID!) { node(id: $id) { diff --git a/scripts/finance/index.js b/scripts/finance/index.js index c5ab35346c0d..f0ed465b8475 100644 --- a/scripts/finance/index.js +++ b/scripts/finance/index.js @@ -1,10 +1,8 @@ -const { - promises: { mkdir } -} = require('fs'); -const { resolve } = require('path'); -const writeJSON = require('../utils/readAndWriteJson.js'); +import { resolve } from 'path'; +import { mkdir } from 'fs/promises'; +import { writeJSON } from '../utils/readAndWriteJson.js'; -module.exports = async function buildFinanceInfoList({ currentDir, configDir, financeDir, year, jsonDataDir }) { +export async function buildFinanceInfoList({ currentDir, configDir, financeDir, year, jsonDataDir }) { try { const expensesPath = resolve(currentDir, configDir, financeDir, year, 'Expenses.yml'); const expensesLinkPath = resolve(currentDir, configDir, financeDir, year, 'ExpensesLink.yml'); @@ -22,4 +20,4 @@ module.exports = async function buildFinanceInfoList({ currentDir, configDir, fi } catch (err) { throw new Error(err); } -}; +} diff --git a/scripts/index.js b/scripts/index.js index afe99ff7ca11..1211c9fe54e4 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -1,11 +1,14 @@ -const { resolve } = require('path'); -const fs = require('fs'); -const rssFeed = require('./build-rss'); -const buildPostList = require('./build-post-list'); -const buildCaseStudiesList = require('./casestudies'); -const buildAdoptersList = require('./adopters'); -const buildFinanceInfoList = require('./finance'); +import { resolve, dirname } from 'path'; +import fs from 'fs'; +import { fileURLToPath } from 'url'; +import { rssFeed } from './build-rss.js'; +import { buildPostList } from './build-post-list.js'; +import { buildCaseStudiesList } from './casestudies/index.js'; +import { buildAdoptersList } from './adopters/index.js'; +import { buildFinanceInfoList } from './finance/index.js'; +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); async function start() { await buildPostList(); rssFeed('blog', 'AsyncAPI Initiative Blog RSS Feed', 'AsyncAPI Initiative Blog', 'rss.xml'); @@ -40,6 +43,6 @@ async function start() { }); } -module.exports = start; +export { start }; start(); diff --git a/scripts/markdown/check-markdown.js b/scripts/markdown/check-markdown.js index 7088a1c4d0fc..49fbc74b28f1 100644 --- a/scripts/markdown/check-markdown.js +++ b/scripts/markdown/check-markdown.js @@ -1,6 +1,6 @@ -const fs = require('fs'); -const matter = require('gray-matter'); -const path = require('path'); +import fs from 'fs'; +import matter from 'gray-matter'; +import path from 'path'; /** * Checks if a given string is a valid URL. diff --git a/scripts/tools/categorylist.js b/scripts/tools/categorylist.js index dc81be15a320..3ba7f2583517 100644 --- a/scripts/tools/categorylist.js +++ b/scripts/tools/categorylist.js @@ -103,4 +103,4 @@ const categoryList = [ } ]; -module.exports = { categoryList }; +export { categoryList }; diff --git a/scripts/tools/combine-tools.js b/scripts/tools/combine-tools.js index 01be1ec876dc..2f296412ac1b 100644 --- a/scripts/tools/combine-tools.js +++ b/scripts/tools/combine-tools.js @@ -1,11 +1,11 @@ -const fs = require('fs'); -const Ajv = require('ajv'); -const addFormats = require('ajv-formats'); -const Fuse = require('fuse.js'); -const { languagesColor, technologiesColor } = require('./tags-color'); -const { categoryList } = require('./categorylist.js'); -const { createToolObject } = require('./tools-object'); -const schema = require('./tools-schema.json'); +import fs from 'fs'; +import Ajv from 'ajv'; +import addFormats from 'ajv-formats'; +import Fuse from 'fuse.js'; +import { languagesColor, technologiesColor } from './tags-color.js'; +import { categoryList } from './categorylist.js'; +import { createToolObject } from './tools-object.js'; +import schema from './tools-schema.json'; const ajv = new Ajv(); addFormats(ajv, ['uri']); @@ -139,4 +139,4 @@ const combineTools = async (automatedTools, manualTools, toolsPath, tagsPath) => fs.writeFileSync(tagsPath, JSON.stringify({ languages: languageList, technologies: technologyList })); }; -module.exports = { combineTools }; +export { combineTools }; diff --git a/scripts/tools/extract-tools-github.js b/scripts/tools/extract-tools-github.js index 1db138a95add..71a2a8cbb1f6 100644 --- a/scripts/tools/extract-tools-github.js +++ b/scripts/tools/extract-tools-github.js @@ -1,4 +1,5 @@ -const axios = require('axios'); +import axios from 'axios'; + require('dotenv').config(); const getData = async () => { @@ -16,4 +17,4 @@ const getData = async () => { } }; -module.exports = { getData }; +export { getData }; diff --git a/scripts/tools/tags-color.js b/scripts/tools/tags-color.js index 3483de2b0b08..d6a905060988 100644 --- a/scripts/tools/tags-color.js +++ b/scripts/tools/tags-color.js @@ -175,4 +175,4 @@ const technologiesColor = [ } ]; -module.exports = { languagesColor, technologiesColor }; +export { languagesColor, technologiesColor }; diff --git a/scripts/tools/tools-object.js b/scripts/tools/tools-object.js index 57b152e49570..16b86877784f 100644 --- a/scripts/tools/tools-object.js +++ b/scripts/tools/tools-object.js @@ -1,14 +1,14 @@ -const axios = require('axios'); -const Ajv = require('ajv'); -const addFormats = require('ajv-formats'); -const Fuse = require('fuse.js'); -const schema = require('./tools-schema.json'); -const { categoryList } = require('./categorylist'); +import axios from 'axios'; +import Ajv from 'ajv'; +import addFormats from 'ajv-formats'; +import Fuse from 'fuse.js'; +import schema from './tools-schema.json'; +import { categoryList } from './categorylist'; +import { convertToJson } from '../utils'; const ajv = new Ajv(); addFormats(ajv, ['uri']); const validate = ajv.compile(schema); -const { convertToJson } = require('../utils'); // Config options set for the Fuse object const options = { @@ -115,4 +115,4 @@ async function convertTools(data) { return finalToolsObject; } -module.exports = { convertTools, createToolObject }; +export { convertTools, createToolObject }; diff --git a/scripts/utils.js b/scripts/utils.js index fa893a6de22e..dee033fc9504 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -1,4 +1,4 @@ -const yaml = require('yaml'); +import yaml from 'yaml'; function convertToJson(contentYAMLorJSON) { // Axios handles conversion to JSON by default, if data returned from the server allows it @@ -23,4 +23,4 @@ function convertToJson(contentYAMLorJSON) { } } -module.exports = { convertToJson }; +export { convertToJson }; diff --git a/scripts/utils/readAndWriteJson.js b/scripts/utils/readAndWriteJson.js index e3e2a6f2b6e3..7fca9fd10116 100644 --- a/scripts/utils/readAndWriteJson.js +++ b/scripts/utils/readAndWriteJson.js @@ -1,9 +1,7 @@ -const { - promises: { readFile, writeFile } -} = require('fs'); -const { convertToJson } = require('../utils'); +import { writeFile, readFile } from 'fs/promises'; +import { convertToJson } from '../utils.js'; -module.exports = async function writeJSON(readPath, writePath) { +export async function writeJSON(readPath, writePath) { let readContent; let jsonContent; @@ -27,4 +25,4 @@ module.exports = async function writeJSON(readPath, writePath) { } catch (err) { throw new Error(`Error while writing file\nError: ${err}`); } -}; +} diff --git a/utils/getStatic.ts b/utils/getStatic.ts index 56af2cf6b1ca..98796d580c1b 100644 --- a/utils/getStatic.ts +++ b/utils/getStatic.ts @@ -1,6 +1,6 @@ import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; -import i18nextConfig from '../next-i18next.config'; +import i18nextConfig from '../next-i18next.config.js'; /** * Retrieves the internationalization paths for the supported locales. @@ -9,8 +9,8 @@ import i18nextConfig from '../next-i18next.config'; export const getI18nPaths = () => i18nextConfig.i18n.locales.map((lng) => ({ params: { - lang: lng - } + lang: lng, + }, })); /** @@ -19,7 +19,7 @@ export const getI18nPaths = () => */ export const getStaticPaths = () => ({ fallback: false, - paths: getI18nPaths() + paths: getI18nPaths(), }); /** @@ -31,7 +31,7 @@ export const getStaticPaths = () => ({ export async function getI18nProps(ctx: any, ns = ['common']) { const locale = ctx?.params?.lang; const props = { - ...(await serverSideTranslations(locale, ns)) + ...(await serverSideTranslations(locale, ns)), }; return props; @@ -45,7 +45,7 @@ export async function getI18nProps(ctx: any, ns = ['common']) { export function makeStaticProps(ns = {}) { return async function getStaticProps(ctx: any) { return { - props: await getI18nProps(ctx, ns as any) + props: await getI18nProps(ctx, ns as any), }; }; } diff --git a/utils/languageDetector.ts b/utils/languageDetector.ts index e3db95e0f17d..5af3ded38188 100644 --- a/utils/languageDetector.ts +++ b/utils/languageDetector.ts @@ -1,8 +1,8 @@ import languageDetector from 'next-language-detector'; -import i18nextConfig from '../next-i18next.config'; +import i18nextConfig from '../next-i18next.config.js'; export default languageDetector({ supportedLngs: i18nextConfig.i18n.locales, - fallbackLng: i18nextConfig.i18n.defaultLocale + fallbackLng: i18nextConfig.i18n.defaultLocale, }); From fbb0e61c0a1f228d9babaec2c76049c54fbb64b2 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 00:43:18 +0530 Subject: [PATCH 08/59] rename next config file --- next-i18next.config.js => next-i18next.config.cjs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename next-i18next.config.js => next-i18next.config.cjs (100%) diff --git a/next-i18next.config.js b/next-i18next.config.cjs similarity index 100% rename from next-i18next.config.js rename to next-i18next.config.cjs From fd80ef2e9180c39dcebfd23d927fe85a82ba8eed Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 00:43:25 +0530 Subject: [PATCH 09/59] add new path config --- next-i18next.config.cjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/next-i18next.config.cjs b/next-i18next.config.cjs index 854dbe88c0ac..6ee70f95d5fe 100644 --- a/next-i18next.config.cjs +++ b/next-i18next.config.cjs @@ -1,4 +1,8 @@ -const config = { +// The file is required to be named next-i18next.config.cjs so we can use it in next.config.js. +// https://github.com/i18next/next-i18next/issues/2185#issuecomment-1618307556 +process.env.I18NEXT_DEFAULT_CONFIG_PATH = './next-i18next.config.cjs'; + +module.exports = { i18n: { locales: ['en', 'de'], defaultLocale: 'en', @@ -7,4 +11,3 @@ const config = { react: { useSuspense: false } // this line } }; -export default config; From f5b38a70e3dbbafc4ea00959a555fcfd5b716e75 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 00:44:02 +0530 Subject: [PATCH 10/59] update import names --- pages/_document.tsx | 2 +- utils/getStatic.ts | 2 +- utils/languageDetector.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/_document.tsx b/pages/_document.tsx index b71582a10850..ac793e9eced9 100644 --- a/pages/_document.tsx +++ b/pages/_document.tsx @@ -1,7 +1,7 @@ import Document, { Head, Html, Main, NextScript } from 'next/document'; import React from 'react'; -import i18nextConfig from '../next-i18next.config.js'; +import i18nextConfig from '../next-i18next.config.cjs'; class MyDocument extends Document { static async getInitialProps(ctx: any) { diff --git a/utils/getStatic.ts b/utils/getStatic.ts index 98796d580c1b..304654e6f6de 100644 --- a/utils/getStatic.ts +++ b/utils/getStatic.ts @@ -1,6 +1,6 @@ import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; -import i18nextConfig from '../next-i18next.config.js'; +import i18nextConfig from '../next-i18next.config.cjs'; /** * Retrieves the internationalization paths for the supported locales. diff --git a/utils/languageDetector.ts b/utils/languageDetector.ts index 5af3ded38188..3d4c810dafb2 100644 --- a/utils/languageDetector.ts +++ b/utils/languageDetector.ts @@ -1,6 +1,6 @@ import languageDetector from 'next-language-detector'; -import i18nextConfig from '../next-i18next.config.js'; +import i18nextConfig from '../next-i18next.config.cjs'; export default languageDetector({ supportedLngs: i18nextConfig.i18n.locales, From 7b6c3b9d507878c74b9270ae4bbcfd71bf607e35 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 00:51:18 +0530 Subject: [PATCH 11/59] rename utils file to ts --- scripts/{utils.js => utils.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{utils.js => utils.ts} (100%) diff --git a/scripts/utils.js b/scripts/utils.ts similarity index 100% rename from scripts/utils.js rename to scripts/utils.ts From a8c12ea12cd4bfa370057f586daf4519544638a0 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 12:36:41 +0530 Subject: [PATCH 12/59] add types --- scripts/utils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/utils.ts b/scripts/utils.ts index dee033fc9504..17044631ec5c 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -1,6 +1,6 @@ import yaml from 'yaml'; -function convertToJson(contentYAMLorJSON) { +function convertToJson(contentYAMLorJSON: string) { // Axios handles conversion to JSON by default, if data returned from the server allows it // So if returned content is not a string (not YAML), we just return JSON back if (typeof contentYAMLorJSON !== 'string') { @@ -10,11 +10,13 @@ function convertToJson(contentYAMLorJSON) { // Check if the content is valid JSON before attempting to parse as YAML try { const jsonContent = JSON.parse(contentYAMLorJSON); + return jsonContent; } catch (jsonError) { // If it's not valid JSON, try parsing it as YAML try { const yamlContent = yaml.parse(contentYAMLorJSON); + return yamlContent; } catch (yamlError) { // If parsing as YAML also fails, throw an error From e2097cc3b76acfa254d417ab7a5e7a56b83a1a1f Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 12:36:50 +0530 Subject: [PATCH 13/59] update import --- scripts/casestudies/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/casestudies/index.js b/scripts/casestudies/index.js index 8e5ed249288c..e5dae72ac5a5 100644 --- a/scripts/casestudies/index.js +++ b/scripts/casestudies/index.js @@ -1,5 +1,5 @@ import { readdir, writeFile, readFile } from 'fs/promises'; -import { convertToJson } from '../utils.js'; +import { convertToJson } from '../utils'; export async function buildCaseStudiesList(dirWithCaseStudy, writeFilePath) { try { From c01fb85232dddb02134378c37e55941e78421c14 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 12:37:12 +0530 Subject: [PATCH 14/59] rename --- jest.config.js => jest.config.cjs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jest.config.js => jest.config.cjs (100%) diff --git a/jest.config.js b/jest.config.cjs similarity index 100% rename from jest.config.js rename to jest.config.cjs From c7a7247bf5bb40f85f7610be197b834121bafe53 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 12:37:47 +0530 Subject: [PATCH 15/59] rename to ts --- scripts/{index.js => index.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{index.js => index.ts} (100%) diff --git a/scripts/index.js b/scripts/index.ts similarity index 100% rename from scripts/index.js rename to scripts/index.ts From a49c8a2ad103027094bf69649e8f0e55bf5b9f8e Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 15:01:08 +0530 Subject: [PATCH 16/59] rename compose to ts --- scripts/{compose.js => compose.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{compose.js => compose.ts} (100%) diff --git a/scripts/compose.js b/scripts/compose.ts similarity index 100% rename from scripts/compose.js rename to scripts/compose.ts From 342432a958816d2184327b7e3824e5c006304e9c Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 15:01:43 +0530 Subject: [PATCH 17/59] rename build docs to ts --- scripts/{build-docs.js => build-docs.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{build-docs.js => build-docs.ts} (100%) diff --git a/scripts/build-docs.js b/scripts/build-docs.ts similarity index 100% rename from scripts/build-docs.js rename to scripts/build-docs.ts From 9e8efd8f9d061cbf396682f5c849dd72b90e846f Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 15:03:21 +0530 Subject: [PATCH 18/59] rename build meeting to ts --- scripts/{build-meetings.js => build-meetings.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{build-meetings.js => build-meetings.ts} (100%) diff --git a/scripts/build-meetings.js b/scripts/build-meetings.ts similarity index 100% rename from scripts/build-meetings.js rename to scripts/build-meetings.ts From 2e94f4ca6e81249cf0ba17a9a366c148d07ba308 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 15:03:44 +0530 Subject: [PATCH 19/59] rename build newsroom --- scripts/{build-newsroom-videos.js => build-newsroom-videos.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{build-newsroom-videos.js => build-newsroom-videos.ts} (100%) diff --git a/scripts/build-newsroom-videos.js b/scripts/build-newsroom-videos.ts similarity index 100% rename from scripts/build-newsroom-videos.js rename to scripts/build-newsroom-videos.ts From 6b6c4ea6ef813817e6f25f53a6489e01c6b6f32a Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 15:04:20 +0530 Subject: [PATCH 20/59] rename build postlist to ts --- scripts/{build-post-list.js => build-post-list.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{build-post-list.js => build-post-list.ts} (100%) diff --git a/scripts/build-post-list.js b/scripts/build-post-list.ts similarity index 100% rename from scripts/build-post-list.js rename to scripts/build-post-list.ts From 136bd49dabd592cdf12b5da523dcc4939d96256f Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 15:05:07 +0530 Subject: [PATCH 21/59] rename build rss --- scripts/{build-rss.js => build-rss.ts} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename scripts/{build-rss.js => build-rss.ts} (98%) diff --git a/scripts/build-rss.js b/scripts/build-rss.ts similarity index 98% rename from scripts/build-rss.js rename to scripts/build-rss.ts index bda4c61664cc..5090da207555 100644 --- a/scripts/build-rss.js +++ b/scripts/build-rss.ts @@ -1,6 +1,6 @@ import fs from 'fs/promises'; import json2xml from 'jgexml/json2xml.js'; -import posts from '../config/posts.json' assert { type: 'json' }; +import posts from '../config/posts.json'; function getAllPosts() { return posts; From 3e1536a727d81f46a4f2cdd8535c777f5dd51568 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 15:05:57 +0530 Subject: [PATCH 22/59] rename build tools to ts --- scripts/{build-tools.js => build-tools.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{build-tools.js => build-tools.ts} (100%) diff --git a/scripts/build-tools.js b/scripts/build-tools.ts similarity index 100% rename from scripts/build-tools.js rename to scripts/build-tools.ts From 2528190d1d0cc15ddf2c9a4da673adbab3193d4d Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 15:27:26 +0530 Subject: [PATCH 23/59] rename readWriteJSON to ts --- scripts/utils/{readAndWriteJson.js => readAndWriteJson.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/utils/{readAndWriteJson.js => readAndWriteJson.ts} (100%) diff --git a/scripts/utils/readAndWriteJson.js b/scripts/utils/readAndWriteJson.ts similarity index 100% rename from scripts/utils/readAndWriteJson.js rename to scripts/utils/readAndWriteJson.ts From 34b1cefbe2891fa5b8f3256fd4f8421382114e31 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 15:27:39 +0530 Subject: [PATCH 24/59] add type assertion of json --- scripts/build-rss.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/build-rss.ts b/scripts/build-rss.ts index 5090da207555..cf12e9a79ce7 100644 --- a/scripts/build-rss.ts +++ b/scripts/build-rss.ts @@ -1,6 +1,7 @@ import fs from 'fs/promises'; import json2xml from 'jgexml/json2xml.js'; -import posts from '../config/posts.json'; + +import posts from '../config/posts.json' assert { type: 'json' }; function getAllPosts() { return posts; @@ -13,6 +14,7 @@ function clean(s) { s = s.split('<').join('<'); s = s.split('>').join('>'); s = s.split('"').join('"'); + return s; } @@ -20,12 +22,15 @@ export async function rssFeed(type, title, desc, outputPath) { try { let posts = getAllPosts()[`${type}`]; const missingDatePosts = posts.filter((post) => !post.date); + posts = posts.filter((post) => post.date); posts.sort((i1, i2) => { const i1Date = new Date(i1.date); const i2Date = new Date(i2.date); + if (i1.featured && !i2.featured) return -1; if (!i1.featured && i2.featured) return 1; + return i2Date - i1Date; }); @@ -38,6 +43,7 @@ export async function rssFeed(type, title, desc, outputPath) { const feed = {}; const rss = {}; + rss['@version'] = '2.0'; rss['@xmlns:atom'] = 'http://www.w3.org/2005/Atom'; rss.channel = {}; @@ -75,13 +81,16 @@ export async function rssFeed(type, title, desc, outputPath) { guid, pubDate }; + if (post.cover) { const enclosure = {}; + enclosure['@url'] = base + post.cover; enclosure['@length'] = 15026; // dummy value, anything works enclosure['@type'] = 'image/jpeg'; if (typeof enclosure['@url'] === 'string') { const tmp = enclosure['@url'].toLowerCase(); + if (tmp.indexOf('.png') >= 0) enclosure['@type'] = 'image/png'; if (tmp.indexOf('.svg') >= 0) enclosure['@type'] = 'image/svg+xml'; if (tmp.indexOf('.webp') >= 0) enclosure['@type'] = 'image/webp'; @@ -94,6 +103,7 @@ export async function rssFeed(type, title, desc, outputPath) { feed.rss = rss; const xml = json2xml.getXml(feed, '@', '', 2); + await fs.writeFile(`./public/${outputPath}`, xml, 'utf8'); } catch (err) { throw new Error(`Failed to generate RSS feed: ${err.message}`); From cecc10e6fdc073468f2286cd9035938ab62100ab Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 21 Nov 2024 15:31:06 +0530 Subject: [PATCH 25/59] rename all files to ts --- scripts/adopters/{index.js => index.ts} | 0 scripts/casestudies/{index.js => index.ts} | 0 scripts/dashboard/{build-dashboard.js => build-dashboard.ts} | 0 scripts/dashboard/{issue-queries.js => issue-queries.ts} | 0 scripts/finance/{index.js => index.ts} | 0 scripts/markdown/{check-markdown.js => check-markdown.ts} | 0 scripts/tools/{categorylist.js => categorylist.ts} | 0 scripts/tools/{combine-tools.js => combine-tools.ts} | 0 .../tools/{extract-tools-github.js => extract-tools-github.ts} | 0 scripts/tools/{tags-color.js => tags-color.ts} | 0 scripts/tools/{tools-object.js => tools-object.ts} | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename scripts/adopters/{index.js => index.ts} (100%) rename scripts/casestudies/{index.js => index.ts} (100%) rename scripts/dashboard/{build-dashboard.js => build-dashboard.ts} (100%) rename scripts/dashboard/{issue-queries.js => issue-queries.ts} (100%) rename scripts/finance/{index.js => index.ts} (100%) rename scripts/markdown/{check-markdown.js => check-markdown.ts} (100%) rename scripts/tools/{categorylist.js => categorylist.ts} (100%) rename scripts/tools/{combine-tools.js => combine-tools.ts} (100%) rename scripts/tools/{extract-tools-github.js => extract-tools-github.ts} (100%) rename scripts/tools/{tags-color.js => tags-color.ts} (100%) rename scripts/tools/{tools-object.js => tools-object.ts} (100%) diff --git a/scripts/adopters/index.js b/scripts/adopters/index.ts similarity index 100% rename from scripts/adopters/index.js rename to scripts/adopters/index.ts diff --git a/scripts/casestudies/index.js b/scripts/casestudies/index.ts similarity index 100% rename from scripts/casestudies/index.js rename to scripts/casestudies/index.ts diff --git a/scripts/dashboard/build-dashboard.js b/scripts/dashboard/build-dashboard.ts similarity index 100% rename from scripts/dashboard/build-dashboard.js rename to scripts/dashboard/build-dashboard.ts diff --git a/scripts/dashboard/issue-queries.js b/scripts/dashboard/issue-queries.ts similarity index 100% rename from scripts/dashboard/issue-queries.js rename to scripts/dashboard/issue-queries.ts diff --git a/scripts/finance/index.js b/scripts/finance/index.ts similarity index 100% rename from scripts/finance/index.js rename to scripts/finance/index.ts diff --git a/scripts/markdown/check-markdown.js b/scripts/markdown/check-markdown.ts similarity index 100% rename from scripts/markdown/check-markdown.js rename to scripts/markdown/check-markdown.ts diff --git a/scripts/tools/categorylist.js b/scripts/tools/categorylist.ts similarity index 100% rename from scripts/tools/categorylist.js rename to scripts/tools/categorylist.ts diff --git a/scripts/tools/combine-tools.js b/scripts/tools/combine-tools.ts similarity index 100% rename from scripts/tools/combine-tools.js rename to scripts/tools/combine-tools.ts diff --git a/scripts/tools/extract-tools-github.js b/scripts/tools/extract-tools-github.ts similarity index 100% rename from scripts/tools/extract-tools-github.js rename to scripts/tools/extract-tools-github.ts diff --git a/scripts/tools/tags-color.js b/scripts/tools/tags-color.ts similarity index 100% rename from scripts/tools/tags-color.js rename to scripts/tools/tags-color.ts diff --git a/scripts/tools/tools-object.js b/scripts/tools/tools-object.ts similarity index 100% rename from scripts/tools/tools-object.js rename to scripts/tools/tools-object.ts From adb15fecb58e15a7cc8d20bc04acbff8edb513d4 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Fri, 22 Nov 2024 00:27:01 +0530 Subject: [PATCH 26/59] update imports --- scripts/adopters/index.ts | 6 ++++-- scripts/build-docs.ts | 15 ++++++++++++++- scripts/build-meetings.ts | 3 ++- scripts/build-newsroom-videos.ts | 4 +++- scripts/build-post-list.ts | 17 +++++++++++++---- scripts/build-rss.ts | 2 +- scripts/build-tools.ts | 7 ++++--- scripts/casestudies/index.ts | 4 +++- scripts/dashboard/build-dashboard.ts | 27 +++++++++++++++++++-------- scripts/finance/index.ts | 8 ++++++-- scripts/index.ts | 14 ++++++++------ scripts/tools/combine-tools.ts | 28 ++++++++++++++++++++++------ scripts/tools/tools-object.ts | 14 +++++++++----- scripts/utils/readAndWriteJson.ts | 5 +++-- 14 files changed, 111 insertions(+), 43 deletions(-) diff --git a/scripts/adopters/index.ts b/scripts/adopters/index.ts index 9018b80054ac..56235f6677e6 100644 --- a/scripts/adopters/index.ts +++ b/scripts/adopters/index.ts @@ -1,9 +1,11 @@ -import { resolve, dirname } from 'path'; +import { dirname, resolve } from 'path'; import { fileURLToPath } from 'url'; -import { writeJSON } from '../utils/readAndWriteJson.js'; + +import { writeJSON } from '../utils/readAndWriteJson'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); + export async function buildAdoptersList() { writeJSON('config/adopters.yml', resolve(__dirname, '../../config', 'adopters.json')); } diff --git a/scripts/build-docs.ts b/scripts/build-docs.ts index b0183e13cf7b..f63f4914709f 100644 --- a/scripts/build-docs.ts +++ b/scripts/build-docs.ts @@ -39,6 +39,7 @@ function buildNavTree(navItems) { if (!item.isSection) { if (item.sectionId) { const section = tree[item.rootSectionId]?.children[item.sectionId]; + if (!section) { tree[item.rootSectionId].children[item.sectionId] = { item, @@ -62,6 +63,7 @@ function buildNavTree(navItems) { }) .reduce((obj, key) => { obj[key] = allChildren[key]; + return obj; }, {}); @@ -93,15 +95,20 @@ function buildNavTree(navItems) { const convertDocPosts = (docObject) => { try { let docsArray = []; + // certain entries in the DocPosts are either a parent to many posts or itself a post. + docsArray.push(docObject?.item || docObject); if (docObject.children) { const { children } = docObject; + Object.keys(children).forEach((child) => { const docChildArray = convertDocPosts(children[child]); + docsArray = [...docsArray, ...docChildArray]; }); } + return docsArray; } catch (err) { throw new Error('Error in convertDocPosts:', err); @@ -118,8 +125,10 @@ function addDocButtons(docPosts, treePosts) { structuredPosts.push(treePosts[rootElement].item); if (treePosts[rootElement].children) { const { children } = treePosts[rootElement]; + Object.keys(children).forEach((child) => { const docChildArray = convertDocPosts(children[child]); + structuredPosts = [...structuredPosts, ...docChildArray]; }); } @@ -130,11 +139,13 @@ function addDocButtons(docPosts, treePosts) { // Traversing the structuredPosts in order to add `nextPage` and `prevPage` details for each page const countDocPages = structuredPosts.length; + structuredPosts = structuredPosts.map((post, index) => { // post item specifying the root Section or sub-section in the docs are excluded as // they doesn't comprise any Doc Page or content to be shown in website. if (post?.isRootSection || post?.isSection || index == 0) { if (post?.isRootSection || index == 0) rootSections.push(post.title); + return post; } @@ -181,12 +192,14 @@ function addDocButtons(docPosts, treePosts) { } } } + return docPost; }); } catch (err) { throw new Error('An error occurred while adding doc buttons:', err); } + return structuredPosts; } -export { buildNavTree, addDocButtons, convertDocPosts }; +export { addDocButtons, buildNavTree, convertDocPosts }; diff --git a/scripts/build-meetings.ts b/scripts/build-meetings.ts index 4a76d021e853..68a810704fd8 100644 --- a/scripts/build-meetings.ts +++ b/scripts/build-meetings.ts @@ -1,6 +1,6 @@ import { writeFileSync } from 'fs'; -import { resolve } from 'path'; import { google } from 'googleapis'; +import { resolve } from 'path'; async function buildMeetings(writePath) { let auth; @@ -44,6 +44,7 @@ async function buildMeetings(writePath) { }); const eventsForHuman = JSON.stringify(eventsItems, null, ' '); + console.log('The following events got fetched', eventsForHuman); writeFileSync(writePath, eventsForHuman); diff --git a/scripts/build-newsroom-videos.ts b/scripts/build-newsroom-videos.ts index 7cd4917c7199..e78b0ffd9af1 100644 --- a/scripts/build-newsroom-videos.ts +++ b/scripts/build-newsroom-videos.ts @@ -1,6 +1,6 @@ import { writeFileSync } from 'fs'; -import { resolve } from 'path'; import fetch from 'node-fetch'; +import { resolve } from 'path'; async function buildNewsroomVideos(writePath) { try { @@ -21,6 +21,7 @@ async function buildNewsroomVideos(writePath) { } const data = await response.json(); + console.log(data); if (!data.items || !Array.isArray(data.items)) { @@ -35,6 +36,7 @@ async function buildNewsroomVideos(writePath) { })); const videoData = JSON.stringify(videoDataItems, null, ' '); + console.log('The following are the Newsroom Youtube videos: ', videoData); writeFileSync(writePath, videoData); diff --git a/scripts/build-post-list.ts b/scripts/build-post-list.ts index 946cc6456166..2e4c56a3eec7 100644 --- a/scripts/build-post-list.ts +++ b/scripts/build-post-list.ts @@ -1,12 +1,13 @@ -import { readFileSync, writeFileSync, readdirSync, statSync, existsSync } from 'fs'; -import { resolve, basename, dirname } from 'path'; +import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from 'fs'; import frontMatter from 'gray-matter'; +import { markdownToTxt } from 'markdown-to-txt'; import toc from 'markdown-toc'; import markdownTocUtils from 'markdown-toc/lib/utils.js'; +import { basename, dirname, resolve } from 'path'; import readingTime from 'reading-time'; -import { markdownToTxt } from 'markdown-to-txt'; import { fileURLToPath } from 'url'; -import { buildNavTree, addDocButtons } from './build-docs.js'; + +import { addDocButtons, buildNavTree } from './build-docs'; const { slugify } = markdownTocUtils; @@ -40,6 +41,7 @@ const addItem = (details) => { export async function buildPostList() { walkDirectories(postDirectories, result); const treePosts = buildNavTree(result.docs.filter((p) => p.slug.startsWith('/docs/'))); + result.docsTree = treePosts; result.docs = addDocButtons(result.docs, treePosts); if (process.env.NODE_ENV === 'production') { @@ -60,6 +62,7 @@ function walkDirectories(directories, result, sectionWeight = 0, sectionTitle, s const fileNameWithSection = [fileName, '_section.mdx'].join('/'); const slug = fileName.replace(new RegExp(`^${basePath}`), ''); const slugElements = slug.split('/'); + if (isDirectory(fileName)) { if (existsSync(fileNameWithSection)) { // Passing a second argument to frontMatter disables cache. See https://github.com/asyncapi/website/issues/1057 @@ -83,11 +86,13 @@ function walkDirectories(directories, result, sectionWeight = 0, sectionTitle, s details.slug = slug; addItem(details); const rootId = details.parent || details.rootSectionId; + walkDirectories([[fileName, slug]], result, details.weight, details.title, details.sectionId, rootId); } else if (file.endsWith('.mdx') && !fileName.endsWith('/_section.mdx')) { const fileContent = readFileSync(fileName, 'utf-8'); // Passing a second argument to frontMatter disables cache. See https://github.com/asyncapi/website/issues/1057 const { data, content } = frontMatter(fileContent, {}); + details = data; details.toc = toc(content, { slugify: slugifyToC }).json; details.readingTime = Math.ceil(readingTime(content).minutes); @@ -103,6 +108,7 @@ function walkDirectories(directories, result, sectionWeight = 0, sectionTitle, s if (details.slug.includes('/reference/specification/') && !details.title) { const fileBaseName = basename(data.slug); // ex. v2.0.0 | v2.1.0-next-spec.1 const fileName = fileBaseName.split('-')[0]; // v2.0.0 | v2.1.0 + details.weight = specWeight--; if (fileName.startsWith('v')) { @@ -146,13 +152,16 @@ function slugifyToC(str) { let slug; // Try to match heading ids like {# myHeadingId} const headingIdMatch = str.match(/[\s]?\{\#([\w\d\-_]+)\}/); + if (headingIdMatch && headingIdMatch.length >= 2) { slug = headingIdMatch[1]; } else { // Try to match heading ids like {} const anchorTagMatch = str.match(/[\s]*= 2) slug = anchorTagMatch[1]; } + return slug || slugify(str, { firsth1: true, maxdepth: 6 }); } diff --git a/scripts/build-rss.ts b/scripts/build-rss.ts index cf12e9a79ce7..77700c192fa0 100644 --- a/scripts/build-rss.ts +++ b/scripts/build-rss.ts @@ -1,5 +1,5 @@ import fs from 'fs/promises'; -import json2xml from 'jgexml/json2xml.js'; +import json2xml from 'jgexml/json2xml'; import posts from '../config/posts.json' assert { type: 'json' }; diff --git a/scripts/build-tools.ts b/scripts/build-tools.ts index 47e0d806faa7..e18ea0a24611 100644 --- a/scripts/build-tools.ts +++ b/scripts/build-tools.ts @@ -1,8 +1,9 @@ import fs from 'fs-extra'; import { resolve } from 'path'; -import { getData } from './tools/extract-tools-github.js'; -import { convertTools } from './tools/tools-object.js'; -import { combineTools } from './tools/combine-tools.js'; + +import { combineTools } from './tools/combine-tools'; +import { getData } from './tools/extract-tools-github'; +import { convertTools } from './tools/tools-object'; const buildTools = async (automatedToolsPath, manualToolsPath, toolsPath, tagsPath) => { try { diff --git a/scripts/casestudies/index.ts b/scripts/casestudies/index.ts index e5dae72ac5a5..7aa77b59d787 100644 --- a/scripts/casestudies/index.ts +++ b/scripts/casestudies/index.ts @@ -1,10 +1,12 @@ -import { readdir, writeFile, readFile } from 'fs/promises'; +import { readdir, readFile, writeFile } from 'fs/promises'; + import { convertToJson } from '../utils'; export async function buildCaseStudiesList(dirWithCaseStudy, writeFilePath) { try { const files = await readdir(dirWithCaseStudy); const caseStudiesList = []; + for (const file of files) { const caseStudyFileName = [dirWithCaseStudy, file].join('/'); const caseStudyContent = await readFile(caseStudyFileName, 'utf-8'); diff --git a/scripts/dashboard/build-dashboard.ts b/scripts/dashboard/build-dashboard.ts index 07489c2eae59..b616111484f2 100644 --- a/scripts/dashboard/build-dashboard.ts +++ b/scripts/dashboard/build-dashboard.ts @@ -1,6 +1,7 @@ +import { graphql } from '@octokit/graphql'; import { writeFile } from 'fs-extra'; import { resolve } from 'path'; -import { graphql } from '@octokit/graphql'; + import { Queries } from './issue-queries'; /** @@ -26,7 +27,7 @@ async function getDiscussions(query, pageSize, endCursor = null) { if (result.rateLimit.remaining <= 100) { console.log( - `[WARNING] GitHub GraphQL rateLimit`, + '[WARNING] GitHub GraphQL rateLimit', `cost = ${result.rateLimit.cost}`, `limit = ${result.rateLimit.limit}`, `remaining = ${result.rateLimit.remaining}`, @@ -41,9 +42,11 @@ async function getDiscussions(query, pageSize, endCursor = null) { if (!hasNextPage) { return result.search.nodes; } + return result.search.nodes.concat(await getDiscussions(query, pageSize, result.search.pageInfo.endCursor)); } catch (e) { console.error(e); + return Promise.reject(e); } } @@ -60,6 +63,7 @@ async function getDiscussionByID(isPR, id) { return result; } catch (e) { console.error(e); + return Promise.reject(e); } } @@ -69,8 +73,10 @@ async function processHotDiscussions(batch) { batch.map(async (discussion) => { try { const isPR = discussion.__typename === 'PullRequest'; + if (discussion.comments.pageInfo.hasNextPage) { const fetchedDiscussion = await getDiscussionByID(isPR, discussion.id); + discussion = fetchedDiscussion.node; } @@ -111,12 +117,14 @@ async function getHotDiscussions(discussions) { for (let i = 0; i < discussions.length; i += batchSize) { const batch = discussions.slice(i, i + batchSize); const batchResults = await processHotDiscussions(batch); + await pause(1000); result.push(...batchResults); } result.sort((ElemA, ElemB) => ElemB.score - ElemA.score); const filteredResult = result.filter((issue) => issue.author !== 'asyncapi-bot'); + return filteredResult.slice(0, 12); } @@ -149,6 +157,7 @@ async function mapGoodFirstIssues(issues) { function getLabel(issue, filter) { const result = issue.labels.nodes.find((label) => label.name.startsWith(filter)); + return result?.name.split('/')[1]; } @@ -156,6 +165,7 @@ function monthsSince(date) { const seconds = Math.floor((new Date() - new Date(date)) / 1000); // 2592000 = number of seconds in a month = 30 * 24 * 60 * 60 const months = seconds / 2592000; + return Math.floor(months); } @@ -169,6 +179,7 @@ async function start(writePath) { getHotDiscussions(discussions), mapGoodFirstIssues(rawGoodFirstIssues) ]); + return await writeToFile({ hotDiscussions, goodFirstIssues }, writePath); } catch (e) { console.log('There were some issues parsing data from github.'); @@ -182,13 +193,13 @@ if (require.main === module) { } export { - getLabel, - monthsSince, - mapGoodFirstIssues, - getHotDiscussions, getDiscussionByID, getDiscussions, - writeToFile, + getHotDiscussions, + getLabel, + mapGoodFirstIssues, + monthsSince, + processHotDiscussions, start, - processHotDiscussions + writeToFile }; diff --git a/scripts/finance/index.ts b/scripts/finance/index.ts index f0ed465b8475..34d08fe4f88e 100644 --- a/scripts/finance/index.ts +++ b/scripts/finance/index.ts @@ -1,6 +1,7 @@ -import { resolve } from 'path'; import { mkdir } from 'fs/promises'; -import { writeJSON } from '../utils/readAndWriteJson.js'; +import { resolve } from 'path'; + +import { writeJSON } from '../utils/readAndWriteJson'; export async function buildFinanceInfoList({ currentDir, configDir, financeDir, year, jsonDataDir }) { try { @@ -9,13 +10,16 @@ export async function buildFinanceInfoList({ currentDir, configDir, financeDir, // Ensure the directory exists before writing the files const jsonDirectory = resolve(currentDir, configDir, financeDir, jsonDataDir); + await mkdir(jsonDirectory, { recursive: true }); // Write Expenses and ExpensesLink to JSON files const expensesJsonPath = resolve(jsonDirectory, 'Expenses.json'); + await writeJSON(expensesPath, expensesJsonPath); const expensesLinkJsonPath = resolve(jsonDirectory, 'ExpensesLink.json'); + await writeJSON(expensesLinkPath, expensesLinkJsonPath); } catch (err) { throw new Error(err); diff --git a/scripts/index.ts b/scripts/index.ts index 1211c9fe54e4..fa6bb97afa7f 100644 --- a/scripts/index.ts +++ b/scripts/index.ts @@ -1,14 +1,16 @@ -import { resolve, dirname } from 'path'; import fs from 'fs'; +import { dirname, resolve } from 'path'; import { fileURLToPath } from 'url'; -import { rssFeed } from './build-rss.js'; -import { buildPostList } from './build-post-list.js'; -import { buildCaseStudiesList } from './casestudies/index.js'; -import { buildAdoptersList } from './adopters/index.js'; -import { buildFinanceInfoList } from './finance/index.js'; + +import { buildAdoptersList } from './adopters/index'; +import { buildPostList } from './build-post-list'; +import { rssFeed } from './build-rss'; +import { buildCaseStudiesList } from './casestudies/index'; +import { buildFinanceInfoList } from './finance/index'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); + async function start() { await buildPostList(); rssFeed('blog', 'AsyncAPI Initiative Blog RSS Feed', 'AsyncAPI Initiative Blog', 'rss.xml'); diff --git a/scripts/tools/combine-tools.ts b/scripts/tools/combine-tools.ts index 2f296412ac1b..60f984cf1a0e 100644 --- a/scripts/tools/combine-tools.ts +++ b/scripts/tools/combine-tools.ts @@ -1,17 +1,20 @@ -import fs from 'fs'; import Ajv from 'ajv'; import addFormats from 'ajv-formats'; -import Fuse from 'fuse.js'; -import { languagesColor, technologiesColor } from './tags-color.js'; -import { categoryList } from './categorylist.js'; -import { createToolObject } from './tools-object.js'; +import fs from 'fs'; +import Fuse from 'fuse'; + +import { categoryList } from './categorylist'; +import { languagesColor, technologiesColor } from './tags-color'; +import { createToolObject } from './tools-object'; import schema from './tools-schema.json'; const ajv = new Ajv(); + addFormats(ajv, ['uri']); const validate = ajv.compile(schema); const finalTools = {}; + for (const category of categoryList) { finalTools[category.name] = { description: category.description, @@ -42,8 +45,10 @@ const getFinalTool = async (toolObject) => { // there might be a tool without language if (toolObject.filters.language) { const languageArray = []; + if (typeof toolObject.filters.language === 'string') { const languageSearch = await languageFuse.search(toolObject.filters.language); + if (languageSearch.length) { languageArray.push(languageSearch[0].item); } else { @@ -54,6 +59,7 @@ const getFinalTool = async (toolObject) => { color: 'bg-[#57f281]', borderColor: 'border-[#37f069]' }; + languageList.push(languageObject); languageArray.push(languageObject); languageFuse = new Fuse(languageList, options); @@ -61,6 +67,7 @@ const getFinalTool = async (toolObject) => { } else { for (const language of toolObject?.filters?.language) { const languageSearch = await languageFuse.search(language); + if (languageSearch.length > 0) { languageArray.push(languageSearch[0].item); } else { @@ -71,6 +78,7 @@ const getFinalTool = async (toolObject) => { color: 'bg-[#57f281]', borderColor: 'border-[#37f069]' }; + languageList.push(languageObject); languageArray.push(languageObject); languageFuse = new Fuse(languageList, options); @@ -80,9 +88,11 @@ const getFinalTool = async (toolObject) => { finalObject.filters.language = languageArray; } const technologyArray = []; + if (toolObject.filters.technology) { for (const technology of toolObject?.filters?.technology) { const technologySearch = await technologyFuse.search(technology); + if (technologySearch.length > 0) { technologyArray.push(technologySearch[0].item); } else { @@ -93,6 +103,7 @@ const getFinalTool = async (toolObject) => { color: 'bg-[#61d0f2]', borderColor: 'border-[#40ccf7]' }; + technologyList.push(technologyObject); technologyArray.push(technologyObject); technologyFuse = new Fuse(technologyList, options); @@ -100,6 +111,7 @@ const getFinalTool = async (toolObject) => { } } finalObject.filters.technology = technologyArray; + return finalObject; }; @@ -108,6 +120,7 @@ const getFinalTool = async (toolObject) => { const combineTools = async (automatedTools, manualTools, toolsPath, tagsPath) => { for (const key in automatedTools) { const finalToolsList = []; + if (automatedTools[key].toolsList.length) { for (const tool of automatedTools[key].toolsList) { finalToolsList.push(await getFinalTool(tool)); @@ -117,17 +130,20 @@ const combineTools = async (automatedTools, manualTools, toolsPath, tagsPath) => for (const tool of manualTools[key].toolsList) { let isAsyncAPIrepo; const isValid = await validate(tool); + if (isValid) { if (tool?.links?.repoUrl) { const url = new URL(tool.links.repoUrl); + isAsyncAPIrepo = url.href.startsWith('https://github.com/asyncapi/'); } else isAsyncAPIrepo = false; const toolObject = await createToolObject(tool, '', '', isAsyncAPIrepo); + finalToolsList.push(await getFinalTool(toolObject)); } else { console.error('Script is not failing, it is just dropping errors for further investigation'); console.error(`Invalid ${tool.title} .asyncapi-tool file.`); - console.error(`Located in manual-tools.json file`); + console.error('Located in manual-tools.json file'); console.error('Validation errors:', JSON.stringify(validate.errors, null, 2)); } } diff --git a/scripts/tools/tools-object.ts b/scripts/tools/tools-object.ts index 16b86877784f..5482daa91898 100644 --- a/scripts/tools/tools-object.ts +++ b/scripts/tools/tools-object.ts @@ -1,12 +1,14 @@ -import axios from 'axios'; import Ajv from 'ajv'; import addFormats from 'ajv-formats'; +import axios from 'axios'; import Fuse from 'fuse.js'; -import schema from './tools-schema.json'; -import { categoryList } from './categorylist'; + import { convertToJson } from '../utils'; +import { categoryList } from './categorylist'; +import schema from './tools-schema.json'; const ajv = new Ajv(); + addFormats(ajv, ['uri']); const validate = ajv.compile(schema); @@ -39,6 +41,7 @@ const createToolObject = async (toolFile, repositoryUrl = '', repoDescription = isAsyncAPIOwner: isAsyncAPIrepo } }; + return resultantObject; }; @@ -92,8 +95,8 @@ async function convertTools(data) { if (categorySearch.length) { const searchedCategoryName = categorySearch[0].item.name; - if (!finalToolsObject[searchedCategoryName].toolsList.find((element) => element === toolObject)) - finalToolsObject[searchedCategoryName].toolsList.push(toolObject); + + if (!finalToolsObject[searchedCategoryName].toolsList.find((element) => element === toolObject)) finalToolsObject[searchedCategoryName].toolsList.push(toolObject); } else { // if Tool object has a category, not defined in our categorylist, then this provides a `other` category to the tool. if (!finalToolsObject.Others.toolsList.find((element) => element === toolObject)) @@ -112,6 +115,7 @@ async function convertTools(data) { throw err; } } + return finalToolsObject; } diff --git a/scripts/utils/readAndWriteJson.ts b/scripts/utils/readAndWriteJson.ts index 7fca9fd10116..0b8721a8379b 100644 --- a/scripts/utils/readAndWriteJson.ts +++ b/scripts/utils/readAndWriteJson.ts @@ -1,5 +1,6 @@ -import { writeFile, readFile } from 'fs/promises'; -import { convertToJson } from '../utils.js'; +import { readFile, writeFile } from 'fs/promises'; + +import { convertToJson } from '../utils'; export async function writeJSON(readPath, writePath) { let readContent; From a05df3f8137d4c27a08613bd30ded1e55d723f66 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Fri, 22 Nov 2024 00:32:46 +0530 Subject: [PATCH 27/59] update file extentions --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 13ce5e81207a..7cf2290b00bd 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,9 @@ "build": "npm run build-scripts && next build", "test": "jest --passWithNoTests", "build:pages": "node --loader ts-node/esm scripts/build-pages.ts && npm run format:mdx", - "build:posts": "node scripts/index.js", + "build:posts": "node --loader ts-node/esm scripts/index.ts", "build-scripts": "npm run build:pages && npm run lint:mdx && npm run build:posts", - "write:blog": "node ./scripts/compose.js", + "write:blog": "node --loader ts-node/esm ./scripts/compose.ts", "start": "npx serve@latest out", "export": "next export", "lint": "next lint", @@ -19,12 +19,12 @@ "format:mdx": "prettier --write \"**/*.mdx\"", "lint:mdx": "remark \"**/*.mdx\"", "generate:assets": "echo \"No assets to configure\"", - "generate:meetings": "node scripts/build-meetings.js", - "generate:dashboard": "node scripts/dashboard/build-dashboard.js", - "generate:videos": "node scripts/build-newsroom-videos.js", - "generate:tools": "node scripts/build-tools.js", + "generate:meetings": "node --loader ts-node/esm scripts/build-meetings.ts", + "generate:dashboard": "node --loader ts-node/esm scripts/dashboard/build-dashboard.ts", + "generate:videos": "node --loader ts-node/esm scripts/build-newsroom-videos.ts", + "generate:tools": "node --loader ts-node/esm scripts/build-tools.ts", "test:netlify": "deno test --allow-env --trace-ops netlify/**/*.test.ts", - "test:md": "node scripts/markdown/check-markdown.js", + "test:md": "node --loader ts-node/esm scripts/markdown/check-markdown.ts", "dev:storybook": "storybook dev -p 6006", "build:storybook": "storybook build" }, From 8cb082b484cf3fcb45b807cd2c59aadba7e5d5a5 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Fri, 22 Nov 2024 00:40:32 +0530 Subject: [PATCH 28/59] add ts-node config --- tsconfig.json | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index d7c7683d9403..0d6447d7f8c6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,18 @@ "@/*": ["./*"] } }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "types/**/*.d.ts", "**/*.json"], - "exclude": ["node_modules", "netlify"] + "include": [ + "next-env.d.ts", + "**/*.ts", + "**/*.tsx", + "types/**/*.d.ts", + "**/*.json" + ], + "exclude": ["node_modules", "netlify"], + "include": ["scripts/**/*"], + "ts-node": { + "esm": true, + "experimentalSpecifierResolution": "node", + "transpileOnly": true + } } From b656d31c8320afaf2322aeb6be444fe4c6663607 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Fri, 22 Nov 2024 18:35:28 +0530 Subject: [PATCH 29/59] fix eslint issues. use promise.all instead of await in a loop --- scripts/casestudies/index.ts | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/scripts/casestudies/index.ts b/scripts/casestudies/index.ts index 7aa77b59d787..1db47f373e0c 100644 --- a/scripts/casestudies/index.ts +++ b/scripts/casestudies/index.ts @@ -2,20 +2,25 @@ import { readdir, readFile, writeFile } from 'fs/promises'; import { convertToJson } from '../utils'; -export async function buildCaseStudiesList(dirWithCaseStudy, writeFilePath) { +export async function buildCaseStudiesList(dirWithCaseStudy: string, writeFilePath: string) { try { const files = await readdir(dirWithCaseStudy); - const caseStudiesList = []; - for (const file of files) { - const caseStudyFileName = [dirWithCaseStudy, file].join('/'); - const caseStudyContent = await readFile(caseStudyFileName, 'utf-8'); - const jsonContent = convertToJson(caseStudyContent); + // Process all files in parallel using Promise.all + const caseStudiesList = await Promise.all( + files.map(async (file) => { + const caseStudyFileName = [dirWithCaseStudy, file].join('/'); + const caseStudyContent = await readFile(caseStudyFileName, 'utf-8'); - caseStudiesList.push(jsonContent); - await writeFile(writeFilePath, JSON.stringify(caseStudiesList)); - } + return convertToJson(caseStudyContent); + }) + ); + + // Write the complete list once after all files are processed + await writeFile(writeFilePath, JSON.stringify(caseStudiesList)); + + return caseStudiesList; } catch (err) { - throw new Error(err); + throw new Error(err instanceof Error ? err.message : String(err)); } } From 717135f5bb80d993f25364307842daa9e7676185 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Fri, 22 Nov 2024 19:27:34 +0530 Subject: [PATCH 30/59] fix eslint error --- scripts/build-pages.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build-pages.ts b/scripts/build-pages.ts index ed6eda670f98..901adc8c4947 100644 --- a/scripts/build-pages.ts +++ b/scripts/build-pages.ts @@ -16,6 +16,7 @@ export function capitalizeJsxTags(content: string) { if (capitalizeTags.includes(letter.toLowerCase())) { return `<${match[1] === '/' ? '/' : ''}${letter[0].toUpperCase()}${letter.slice(1)}`; } + return match; }); } From e8e30ebf8576d0cfcc22839488816f29fb4f7637 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Fri, 22 Nov 2024 19:31:43 +0530 Subject: [PATCH 31/59] rename --- scripts/utils/{readAndWriteJson.ts => readAndWriteJson.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/utils/{readAndWriteJson.ts => readAndWriteJson.js} (100%) diff --git a/scripts/utils/readAndWriteJson.ts b/scripts/utils/readAndWriteJson.js similarity index 100% rename from scripts/utils/readAndWriteJson.ts rename to scripts/utils/readAndWriteJson.js From 212e5485c02e61d064f24be51e20df21af4e7fb3 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Fri, 22 Nov 2024 19:31:49 +0530 Subject: [PATCH 32/59] rename --- scripts/utils/{readAndWriteJson.js => readAndWriteJson.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/utils/{readAndWriteJson.js => readAndWriteJson.ts} (100%) diff --git a/scripts/utils/readAndWriteJson.js b/scripts/utils/readAndWriteJson.ts similarity index 100% rename from scripts/utils/readAndWriteJson.js rename to scripts/utils/readAndWriteJson.ts From d3acd8158deadcbcb41409d077908226e9c4d2b3 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Sat, 23 Nov 2024 18:35:02 +0530 Subject: [PATCH 33/59] fix eslint error --- scripts/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/index.ts b/scripts/index.ts index fa6bb97afa7f..96fcafcb384e 100644 --- a/scripts/index.ts +++ b/scripts/index.ts @@ -8,13 +8,13 @@ import { rssFeed } from './build-rss'; import { buildCaseStudiesList } from './casestudies/index'; import { buildFinanceInfoList } from './finance/index'; -const __filename = fileURLToPath(import.meta.url); -const __dirname = dirname(__filename); +const currentFilePath = fileURLToPath(import.meta.url); +const currentDirPath = dirname(currentFilePath); async function start() { await buildPostList(); rssFeed('blog', 'AsyncAPI Initiative Blog RSS Feed', 'AsyncAPI Initiative Blog', 'rss.xml'); - await buildCaseStudiesList('config/casestudies', resolve(__dirname, '../config', 'case-studies.json')); + await buildCaseStudiesList('config/casestudies', resolve(currentDirPath, '../config', 'case-studies.json')); await buildAdoptersList(); const financeDir = resolve('.', 'config', 'finance'); From 09a2fccc62c5d5cd72cbe82a98495f0f375482d5 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Sat, 23 Nov 2024 18:46:20 +0530 Subject: [PATCH 34/59] add error type --- scripts/build-tools.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/build-tools.ts b/scripts/build-tools.ts index e18ea0a24611..114d481cc0a5 100644 --- a/scripts/build-tools.ts +++ b/scripts/build-tools.ts @@ -1,3 +1,4 @@ +import assert from 'assert'; import fs from 'fs-extra'; import { resolve } from 'path'; @@ -5,7 +6,7 @@ import { combineTools } from './tools/combine-tools'; import { getData } from './tools/extract-tools-github'; import { convertTools } from './tools/tools-object'; -const buildTools = async (automatedToolsPath, manualToolsPath, toolsPath, tagsPath) => { +const buildTools = async (automatedToolsPath: string, manualToolsPath: string, toolsPath: string, tagsPath: string) => { try { const githubExtractData = await getData(); const automatedTools = await convertTools(githubExtractData); @@ -14,6 +15,7 @@ const buildTools = async (automatedToolsPath, manualToolsPath, toolsPath, tagsPa await combineTools(automatedTools, require(manualToolsPath), toolsPath, tagsPath); } catch (err) { + assert(err instanceof Error); throw new Error(`An error occurred while building tools: ${err.message}`); } }; From f5fac70475a7a589c2a878c7191c452e3f2e5c6e Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Sat, 23 Nov 2024 18:46:29 +0530 Subject: [PATCH 35/59] add new types --- package-lock.json | 40 ++++++++++++++++++++++++++++++++++++++++ package.json | 2 ++ 2 files changed, 42 insertions(+) diff --git a/package-lock.json b/package-lock.json index 82a8b0119b9b..48e2778e309d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -93,6 +93,8 @@ "@storybook/nextjs": "^8.2.4", "@storybook/react": "^8.2.4", "@storybook/test": "^8.2.4", + "@types/fs-extra": "^11.0.4", + "@types/inquirer": "^9.0.7", "@types/lodash": "^4.17.0", "@types/node": "^20", "@types/react": "^18.0.1", @@ -7602,6 +7604,16 @@ "@types/send": "*" } }, + "node_modules/@types/fs-extra": { + "version": "11.0.4", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.4.tgz", + "integrity": "sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==", + "dev": true, + "dependencies": { + "@types/jsonfile": "*", + "@types/node": "*" + } + }, "node_modules/@types/geojson": { "version": "7946.0.14", "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.14.tgz", @@ -7644,6 +7656,16 @@ "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz", "integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==" }, + "node_modules/@types/inquirer": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/@types/inquirer/-/inquirer-9.0.7.tgz", + "integrity": "sha512-Q0zyBupO6NxGRZut/JdmqYKOnN95Eg5V8Csg3PGKkP+FnvsUZx1jAyK7fztIszxxMuoBA6E3KXWvdZVXIpx60g==", + "dev": true, + "dependencies": { + "@types/through": "*", + "rxjs": "^7.2.0" + } + }, "node_modules/@types/is-empty": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/@types/is-empty/-/is-empty-1.2.3.tgz", @@ -7690,6 +7712,15 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, + "node_modules/@types/jsonfile": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/@types/jsonfile/-/jsonfile-6.1.4.tgz", + "integrity": "sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/lodash": { "version": "4.17.6", "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.6.tgz", @@ -7894,6 +7925,15 @@ "integrity": "sha512-hcZhlNvMkQG/k1vcZ6yHOl6WAYftQ2MLfTHcYRZ2xYZFD8tGVnE3qFV0lj1smQeDSR7/yY0PyuUalauf33bJeA==", "dev": true }, + "node_modules/@types/through": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/@types/through/-/through-0.0.33.tgz", + "integrity": "sha512-HsJ+z3QuETzP3cswwtzt2vEIiHBk/dCcHGhbmG5X3ecnwFD/lPrMpliGXxSCg03L9AhrdwA4Oz/qfspkDW+xGQ==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/unist": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", diff --git a/package.json b/package.json index 7cf2290b00bd..fc38f85d1729 100644 --- a/package.json +++ b/package.json @@ -130,6 +130,8 @@ "@storybook/nextjs": "^8.2.4", "@storybook/react": "^8.2.4", "@storybook/test": "^8.2.4", + "@types/fs-extra": "^11.0.4", + "@types/inquirer": "^9.0.7", "@types/lodash": "^4.17.0", "@types/node": "^20", "@types/react": "^18.0.1", From 2f782e73fb7ad8ec7d7871e8e37cf483d580d4ee Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Sat, 23 Nov 2024 18:46:34 +0530 Subject: [PATCH 36/59] add types --- scripts/compose.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/compose.ts b/scripts/compose.ts index 63c653554b20..764d2cb9556e 100644 --- a/scripts/compose.ts +++ b/scripts/compose.ts @@ -2,15 +2,16 @@ * Script based on https://github.com/timlrx/tailwind-nextjs-starter-blog/blob/master/scripts/compose.js */ +import dedent from 'dedent'; import fs from 'fs'; import inquirer from 'inquirer'; -import dedent from 'dedent'; import moment from 'moment'; -const genFrontMatter = (answers) => { +const genFrontMatter = (answers:ComposePromptType) => { const d = new Date(); const date = [d.getFullYear(), `0${d.getMonth() + 1}`.slice(-2), `0${d.getDate()}`.slice(-2)].join('-'); const tagArray = answers.tags.split(','); + tagArray.forEach((tag, index) => (tagArray[index] = tag.trim())); const tags = `'${tagArray.join("','")}'`; @@ -93,6 +94,14 @@ const genFrontMatter = (answers) => { return frontMatter; }; +type ComposePromptType = { + title: string; + excerpt: string; + tags: string; + type: string; + canonical: string; +} + inquirer .prompt([ { @@ -122,7 +131,7 @@ inquirer type: 'input' } ]) - .then((answers) => { + .then((answers:ComposePromptType) => { // Remove special characters and replace space with - const fileName = answers.title .toLowerCase() @@ -131,6 +140,7 @@ inquirer .replace(/-+/g, '-'); const frontMatter = genFrontMatter(answers); const filePath = `pages/blog/${fileName || 'untitled'}.md`; + fs.writeFile(filePath, frontMatter, { flag: 'wx' }, (err) => { if (err) { throw err; From 1a1f47d835ffa8ff4d97251fe2323f8ff0311990 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Sat, 23 Nov 2024 18:50:27 +0530 Subject: [PATCH 37/59] refactor and fix eslint errors --- scripts/compose.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/compose.ts b/scripts/compose.ts index 764d2cb9556e..3339c51d261b 100644 --- a/scripts/compose.ts +++ b/scripts/compose.ts @@ -7,12 +7,20 @@ import fs from 'fs'; import inquirer from 'inquirer'; import moment from 'moment'; -const genFrontMatter = (answers:ComposePromptType) => { - const d = new Date(); - const date = [d.getFullYear(), `0${d.getMonth() + 1}`.slice(-2), `0${d.getDate()}`.slice(-2)].join('-'); +type ComposePromptType = { + title: string; + excerpt: string; + tags: string; + type: string; + canonical: string; +}; + +const genFrontMatter = (answers: ComposePromptType) => { const tagArray = answers.tags.split(','); - tagArray.forEach((tag, index) => (tagArray[index] = tag.trim())); + tagArray.forEach((tag: string, index: number) => { + tagArray[index] = tag.trim(); + }); const tags = `'${tagArray.join("','")}'`; let frontMatter = dedent`--- @@ -94,14 +102,6 @@ const genFrontMatter = (answers:ComposePromptType) => { return frontMatter; }; -type ComposePromptType = { - title: string; - excerpt: string; - tags: string; - type: string; - canonical: string; -} - inquirer .prompt([ { @@ -131,7 +131,7 @@ inquirer type: 'input' } ]) - .then((answers:ComposePromptType) => { + .then((answers: ComposePromptType) => { // Remove special characters and replace space with - const fileName = answers.title .toLowerCase() From 75a53d4096896e2f80da60d4eec28e38db3253d6 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Sat, 23 Nov 2024 19:34:00 +0530 Subject: [PATCH 38/59] use google apis and add types --- scripts/build-newsroom-videos.ts | 67 ++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/scripts/build-newsroom-videos.ts b/scripts/build-newsroom-videos.ts index e78b0ffd9af1..057a334d3b12 100644 --- a/scripts/build-newsroom-videos.ts +++ b/scripts/build-newsroom-videos.ts @@ -1,26 +1,36 @@ +import assert from 'assert'; import { writeFileSync } from 'fs'; -import fetch from 'node-fetch'; -import { resolve } from 'path'; +import type { youtube_v3 } from 'googleapis'; +import { google } from 'googleapis'; +import { dirname, resolve } from 'path'; +import process from 'process'; +import { fileURLToPath } from 'url'; -async function buildNewsroomVideos(writePath) { +const currentFilePath = fileURLToPath(import.meta.url); +const currentDirPath = dirname(currentFilePath); + +console.log(process.env.YOUTUBE_TOKEN); +const youtube = google.youtube({ + version: 'v3', + auth: process.env.YOUTUBE_TOKEN +}); + +async function buildNewsroomVideos(writePath: string) { try { - const response = await fetch( - `https://youtube.googleapis.com/youtube/v3/search?${new URLSearchParams({ - key: process.env.YOUTUBE_TOKEN, - part: 'snippet', - channelId: 'UCIz9zGwDLbrYQcDKVXdOstQ', - eventType: 'completed', - type: 'video', - order: 'Date', - maxResults: 5 - })}` - ); - - if (!response.ok) { + const response = await youtube.search.list({ + part: ['snippet'], + channelId: 'UCIz9zGwDLbrYQcDKVXdOstQ', + eventType: 'completed', + type: ['video'], + order: 'date', + maxResults: 5 + } as youtube_v3.Params$Resource$Search$List); + + if (response.status !== 200) { throw new Error(`HTTP error! with status code: ${response.status}`); } - const data = await response.json(); + const data = await response.data; console.log(data); @@ -28,12 +38,18 @@ async function buildNewsroomVideos(writePath) { throw new Error('Invalid data structure received from YouTube API'); } - const videoDataItems = data.items.map((video) => ({ - image_url: video.snippet.thumbnails.high.url, - title: video.snippet.title, - description: video.snippet.description, - videoId: video.id.videoId - })); + const videoDataItems = data.items.map((video) => { + if (!video.snippet) { + throw new Error('Invalid data structure received from YouTube API'); + } + + return { + image_url: video.snippet.thumbnails!.high!.url, + title: video.snippet.title, + description: video.snippet.description, + videoId: video.id!.videoId + }; + }); const videoData = JSON.stringify(videoDataItems, null, ' '); @@ -43,13 +59,14 @@ async function buildNewsroomVideos(writePath) { return videoData; } catch (err) { + assert(err instanceof Error); throw new Error(`Failed to build newsroom videos: ${err.message}`); } } /* istanbul ignore next */ -if (require.main === module) { - buildNewsroomVideos(resolve(__dirname, '../config', 'newsroom_videos.json')); +if (process.argv[1] === fileURLToPath(import.meta.url)) { + buildNewsroomVideos(resolve(currentDirPath, '../config', 'newsroom_videos.json')); } export { buildNewsroomVideos }; From 74d199fc0a38f23ee13726bd8fe3b8cf0b14424f Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Sat, 23 Nov 2024 19:34:20 +0530 Subject: [PATCH 39/59] remove console log --- scripts/build-newsroom-videos.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/build-newsroom-videos.ts b/scripts/build-newsroom-videos.ts index 057a334d3b12..100afaa328fa 100644 --- a/scripts/build-newsroom-videos.ts +++ b/scripts/build-newsroom-videos.ts @@ -9,7 +9,6 @@ import { fileURLToPath } from 'url'; const currentFilePath = fileURLToPath(import.meta.url); const currentDirPath = dirname(currentFilePath); -console.log(process.env.YOUTUBE_TOKEN); const youtube = google.youtube({ version: 'v3', auth: process.env.YOUTUBE_TOKEN From 0459723a180a86c01738da8d48943714f962ff62 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Sat, 23 Nov 2024 19:35:36 +0530 Subject: [PATCH 40/59] add specific rules for the script folder --- .eslintrc | 173 ++++++++++++++++++++---------------------------------- 1 file changed, 65 insertions(+), 108 deletions(-) diff --git a/.eslintrc b/.eslintrc index f77da8144e9c..2fe6b4c8dad3 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,18 +4,15 @@ "next/core-web-vitals", "eslint:recommended", "plugin:prettier/recommended", - "plugin:storybook/recommended" + "plugin:storybook/recommended", ], "env": { "browser": true, "es2021": true, "node": true, - "jest": true + "jest": true, }, - "plugins": [ - "react", - "jsx-a11y" - ], + "plugins": ["react", "jsx-a11y"], "rules": { "prettier/prettier": [ "error", @@ -33,47 +30,43 @@ "insertPragma": false, "requirePragma": false, "jsxSingleQuote": true, - "printWidth": 120 - } + "printWidth": 120, + }, ], "max-len": [ "error", { "code": 120, "ignoreUrls": true, - "ignorePattern": "(className=\\{[\\s\\S]*\\}|.*\\}|'.*'|className='.*')" // Ignore classnames - } - ] + "ignorePattern": "(className=\\{[\\s\\S]*\\}|.*\\}|'.*'|className='.*')", // Ignore classnames + }, + ], }, "globals": { "React": true, "expect": true, "jsdom": true, - "JSX": true + "JSX": true, }, "overrides": [ // Configuration for TypeScript files { - "files": [ - "**/*.ts", - "**/*.tsx", - "netlify/*.ts" - ], + "files": ["**/*.ts", "**/*.tsx", "netlify/*.ts"], "plugins": [ "@typescript-eslint", "tailwindcss", "unused-imports", - "simple-import-sort" + "simple-import-sort", ], "extends": [ "plugin:tailwindcss/recommended", "airbnb-typescript", "next/core-web-vitals", "plugin:prettier/recommended", - "plugin:storybook/recommended" + "plugin:storybook/recommended", ], "parserOptions": { - "project": "./tsconfig.json" + "project": "./tsconfig.json", }, "rules": { "react/destructuring-assignment": "off", // Vscode doesn't support automatically destructuring, it's a pain to add a new variable @@ -89,7 +82,7 @@ "error", "ForInStatement", "LabeledStatement", - "WithStatement" + "WithStatement", ], // Overrides Airbnb configuration and enable no-restricted-syntax "import/prefer-default-export": "off", // Named export is easier to refactor automatically "tailwindcss/no-custom-classname": "off", // Disabled otherwise nightmare to allow each custom tailwind classes @@ -101,8 +94,8 @@ "unused-imports/no-unused-vars": [ "error", { - "argsIgnorePattern": "^_" - } + "argsIgnorePattern": "^_", + }, ], // Variables "init-declarations": "off", @@ -126,42 +119,30 @@ "off", "stroustrup", { - "allowSingleLine": true - } + "allowSingleLine": true, + }, ], "camelcase": "off", "capitalized-comments": "off", - "comma-dangle": [ - "error", - "never" - ], + "comma-dangle": ["error", "never"], "comma-spacing": [ 2, { "before": false, - "after": true - } - ], - "comma-style": [ - "error", - "last" + "after": true, + }, ], + "comma-style": ["error", "last"], "eol-last": "error", "func-call-spacing": "error", "func-name-matching": "error", "func-names": "off", "func-style": "off", - "jsx-quotes": [ - "error", - "prefer-single" - ], + "jsx-quotes": ["error", "prefer-single"], "key-spacing": "error", "keyword-spacing": "error", "line-comment-position": "off", - "linebreak-style": [ - "error", - "unix" - ], + "linebreak-style": ["error", "unix"], "lines-around-comment": [ "error", { @@ -174,22 +155,22 @@ "allowObjectStart": true, "allowObjectEnd": false, "allowArrayStart": true, - "allowArrayEnd": false - } + "allowArrayEnd": false, + }, ], "max-depth": "error", "max-lines": [ "error", { - "max": 2000 - } + "max": 2000, + }, ], "max-nested-callbacks": "error", "max-statements-per-line": [ "error", { - "max": 2 - } + "max": 2, + }, ], "multiline-comment-style": "off", "multiline-ternary": "off", @@ -198,13 +179,10 @@ "newline-per-chained-call": [ "error", { - "ignoreChainWithDepth": 4 - } - ], - "newline-after-var": [ - "error", - "always" + "ignoreChainWithDepth": 4, + }, ], + "newline-after-var": ["error", "always"], "no-array-constructor": "error", "no-lonely-if": "error", "no-mixed-operators": "off", @@ -213,8 +191,8 @@ "no-multiple-empty-lines": [ "error", { - "max": 1 - } + "max": 1, + }, ], "no-negated-condition": "error", "no-nested-ternary": "error", @@ -227,63 +205,39 @@ "no-whitespace-before-property": "error", "nonblock-statement-body-position": "error", "object-curly-newline": "off", - "object-curly-spacing": [ - "error", - "always" - ], + "object-curly-spacing": ["error", "always"], "object-property-newline": "off", - "padded-blocks": [ - "error", - "never" - ], + "padded-blocks": ["error", "never"], "padding-line-between-statements": [ "error", { "blankLine": "always", "prev": "*", - "next": "return" + "next": "return", }, { "blankLine": "always", - "prev": [ - "const", - "let", - "var" - ], - "next": "*" + "prev": ["const", "let", "var"], + "next": "*", }, { "blankLine": "any", - "prev": [ - "const", - "let", - "var" - ], - "next": [ - "const", - "let", - "var" - ] - } - ], - "quote-props": [ - "error", - "as-needed" + "prev": ["const", "let", "var"], + "next": ["const", "let", "var"], + }, ], + "quote-props": ["error", "as-needed"], "quotes": [ "error", "single", { - "avoidEscape": true - } + "avoidEscape": true, + }, ], - "require-jsdoc": "warn", + "require-jsdoc": "off", "semi": "error", "semi-spacing": "error", - "semi-style": [ - "error", - "last" - ], + "semi-style": ["error", "last"], "sort-keys": "off", "sort-vars": "off", "space-before-blocks": "error", @@ -296,22 +250,25 @@ "always", { "block": { - "exceptions": [ - "!" - ] - } - } + "exceptions": ["!"], + }, + }, ], - "switch-colon-spacing": "error" - } + "switch-colon-spacing": "error", + }, }, { - "files": [ - "components/logos/*" - ], + "files": ["components/logos/*"], + "rules": { + "max-len": "off", + }, + }, + { + "files": ["scripts/*"], "rules": { - "max-len": "off" - } - } - ] + "import/no-extraneous-dependencies": "off", + "no-console": "off", + }, + }, + ], } From 24ff781ed51f205e0552361e0349eb38ff729559 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Sat, 23 Nov 2024 21:11:54 +0530 Subject: [PATCH 41/59] refactor dir variables --- scripts/adopters/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/adopters/index.ts b/scripts/adopters/index.ts index 56235f6677e6..0e6b9ecfa888 100644 --- a/scripts/adopters/index.ts +++ b/scripts/adopters/index.ts @@ -3,9 +3,10 @@ import { fileURLToPath } from 'url'; import { writeJSON } from '../utils/readAndWriteJson'; -const __filename = fileURLToPath(import.meta.url); -const __dirname = dirname(__filename); + +const currentFilePath = fileURLToPath(import.meta.url); +const currentDirPath = dirname(currentFilePath); export async function buildAdoptersList() { - writeJSON('config/adopters.yml', resolve(__dirname, '../../config', 'adopters.json')); + writeJSON('config/adopters.yml', resolve(currentDirPath, '../../config', 'adopters.json')); } From 39821b700f8e5c427730747d96b0d4c7c825a378 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Sat, 23 Nov 2024 21:16:29 +0530 Subject: [PATCH 42/59] add types and refactor it --- scripts/finance/index.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/finance/index.ts b/scripts/finance/index.ts index 34d08fe4f88e..2fddbf7f41ab 100644 --- a/scripts/finance/index.ts +++ b/scripts/finance/index.ts @@ -1,9 +1,24 @@ +import assert from 'assert'; import { mkdir } from 'fs/promises'; import { resolve } from 'path'; import { writeJSON } from '../utils/readAndWriteJson'; -export async function buildFinanceInfoList({ currentDir, configDir, financeDir, year, jsonDataDir }) { +interface BuildFinanceInfoListProps { + currentDir: string; + configDir: string; + financeDir: string; + year: string; + jsonDataDir: string; +} + +export async function buildFinanceInfoList({ + currentDir, + configDir, + financeDir, + year, + jsonDataDir +}: BuildFinanceInfoListProps) { try { const expensesPath = resolve(currentDir, configDir, financeDir, year, 'Expenses.yml'); const expensesLinkPath = resolve(currentDir, configDir, financeDir, year, 'ExpensesLink.yml'); @@ -22,6 +37,7 @@ export async function buildFinanceInfoList({ currentDir, configDir, financeDir, await writeJSON(expensesLinkPath, expensesLinkJsonPath); } catch (err) { - throw new Error(err); + assert(err instanceof Error); + throw new Error(err.message); } } From 00ed279d454ed5ae05cd1ff4ab099f0fbc7119d1 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Sun, 24 Nov 2024 14:38:10 +0530 Subject: [PATCH 43/59] refactor: update eslint rules --- .eslintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index 2fe6b4c8dad3..bc865d7ebfc0 100644 --- a/.eslintrc +++ b/.eslintrc @@ -264,7 +264,7 @@ }, }, { - "files": ["scripts/*"], + "files": ["scripts/**/*"], "rules": { "import/no-extraneous-dependencies": "off", "no-console": "off", From 8bf03da5ea7ec3eb7695804f764b0424c2fead41 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Sun, 24 Nov 2024 17:25:56 +0530 Subject: [PATCH 44/59] reformat document --- pages/_document.tsx | 44 ++++++++++---------------------------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/pages/_document.tsx b/pages/_document.tsx index ac793e9eced9..fecd327edff1 100644 --- a/pages/_document.tsx +++ b/pages/_document.tsx @@ -12,51 +12,27 @@ class MyDocument extends Document { render() { // eslint-disable-next-line no-underscore-dangle - const currentLocale = - this.props.__NEXT_DATA__.query.locale || i18nextConfig.i18n.defaultLocale; + const currentLocale = this.props.__NEXT_DATA__.query.locale || i18nextConfig.i18n.defaultLocale; return ( {/* Load Work Sans font */} - - + + {/* eslint-disable-next-line max-len */} {/* Icons */} - - - - + + + + - +
From 15ffa2bfc7f9e9685ac44a953a834c1b49c99a1a Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Sun, 24 Nov 2024 18:18:30 +0530 Subject: [PATCH 45/59] update include paths --- tsconfig.json | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 0d6447d7f8c6..fbc1bc06d441 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,15 +16,8 @@ "@/*": ["./*"] } }, - "include": [ - "next-env.d.ts", - "**/*.ts", - "**/*.tsx", - "types/**/*.d.ts", - "**/*.json" - ], + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.json"], "exclude": ["node_modules", "netlify"], - "include": ["scripts/**/*"], "ts-node": { "esm": true, "experimentalSpecifierResolution": "node", From 02e679a7d08eb5a3963ee7241930f5cebff57d78 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Sun, 24 Nov 2024 18:25:33 +0530 Subject: [PATCH 46/59] use dynamic import --- scripts/build-rss.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/build-rss.ts b/scripts/build-rss.ts index 77700c192fa0..9eda115bc4d7 100644 --- a/scripts/build-rss.ts +++ b/scripts/build-rss.ts @@ -1,9 +1,9 @@ import fs from 'fs/promises'; import json2xml from 'jgexml/json2xml'; -import posts from '../config/posts.json' assert { type: 'json' }; +async function getAllPosts() { + const posts = (await import('../config/posts.json', { assert: { type: 'json' } })).default; -function getAllPosts() { return posts; } @@ -20,7 +20,7 @@ function clean(s) { export async function rssFeed(type, title, desc, outputPath) { try { - let posts = getAllPosts()[`${type}`]; + let posts = (await getAllPosts())[`${type}`]; const missingDatePosts = posts.filter((post) => !post.date); posts = posts.filter((post) => post.date); From 227995de28432fd7b3b6a288bc21881384ee51f6 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Tue, 26 Nov 2024 23:12:17 +0530 Subject: [PATCH 47/59] reformat eslintrc --- .eslintrc | 173 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 111 insertions(+), 62 deletions(-) diff --git a/.eslintrc b/.eslintrc index bc865d7ebfc0..176e8dd85088 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,15 +4,18 @@ "next/core-web-vitals", "eslint:recommended", "plugin:prettier/recommended", - "plugin:storybook/recommended", + "plugin:storybook/recommended" ], "env": { "browser": true, "es2021": true, "node": true, - "jest": true, + "jest": true }, - "plugins": ["react", "jsx-a11y"], + "plugins": [ + "react", + "jsx-a11y" + ], "rules": { "prettier/prettier": [ "error", @@ -30,43 +33,47 @@ "insertPragma": false, "requirePragma": false, "jsxSingleQuote": true, - "printWidth": 120, - }, + "printWidth": 120 + } ], "max-len": [ "error", { "code": 120, "ignoreUrls": true, - "ignorePattern": "(className=\\{[\\s\\S]*\\}|.*\\}|'.*'|className='.*')", // Ignore classnames - }, - ], + "ignorePattern": "(className=\\{[\\s\\S]*\\}|.*\\}|'.*'|className='.*')" // Ignore classnames + } + ] }, "globals": { "React": true, "expect": true, "jsdom": true, - "JSX": true, + "JSX": true }, "overrides": [ // Configuration for TypeScript files { - "files": ["**/*.ts", "**/*.tsx", "netlify/*.ts"], + "files": [ + "**/*.ts", + "**/*.tsx", + "netlify/*.ts" + ], "plugins": [ "@typescript-eslint", "tailwindcss", "unused-imports", - "simple-import-sort", + "simple-import-sort" ], "extends": [ "plugin:tailwindcss/recommended", "airbnb-typescript", "next/core-web-vitals", "plugin:prettier/recommended", - "plugin:storybook/recommended", + "plugin:storybook/recommended" ], "parserOptions": { - "project": "./tsconfig.json", + "project": "./tsconfig.json" }, "rules": { "react/destructuring-assignment": "off", // Vscode doesn't support automatically destructuring, it's a pain to add a new variable @@ -82,7 +89,7 @@ "error", "ForInStatement", "LabeledStatement", - "WithStatement", + "WithStatement" ], // Overrides Airbnb configuration and enable no-restricted-syntax "import/prefer-default-export": "off", // Named export is easier to refactor automatically "tailwindcss/no-custom-classname": "off", // Disabled otherwise nightmare to allow each custom tailwind classes @@ -94,8 +101,8 @@ "unused-imports/no-unused-vars": [ "error", { - "argsIgnorePattern": "^_", - }, + "argsIgnorePattern": "^_" + } ], // Variables "init-declarations": "off", @@ -119,30 +126,42 @@ "off", "stroustrup", { - "allowSingleLine": true, - }, + "allowSingleLine": true + } ], "camelcase": "off", "capitalized-comments": "off", - "comma-dangle": ["error", "never"], + "comma-dangle": [ + "error", + "never" + ], "comma-spacing": [ 2, { "before": false, - "after": true, - }, + "after": true + } + ], + "comma-style": [ + "error", + "last" ], - "comma-style": ["error", "last"], "eol-last": "error", "func-call-spacing": "error", "func-name-matching": "error", "func-names": "off", "func-style": "off", - "jsx-quotes": ["error", "prefer-single"], + "jsx-quotes": [ + "error", + "prefer-single" + ], "key-spacing": "error", "keyword-spacing": "error", "line-comment-position": "off", - "linebreak-style": ["error", "unix"], + "linebreak-style": [ + "error", + "unix" + ], "lines-around-comment": [ "error", { @@ -155,22 +174,22 @@ "allowObjectStart": true, "allowObjectEnd": false, "allowArrayStart": true, - "allowArrayEnd": false, - }, + "allowArrayEnd": false + } ], "max-depth": "error", "max-lines": [ "error", { - "max": 2000, - }, + "max": 2000 + } ], "max-nested-callbacks": "error", "max-statements-per-line": [ "error", { - "max": 2, - }, + "max": 2 + } ], "multiline-comment-style": "off", "multiline-ternary": "off", @@ -179,10 +198,13 @@ "newline-per-chained-call": [ "error", { - "ignoreChainWithDepth": 4, - }, + "ignoreChainWithDepth": 4 + } + ], + "newline-after-var": [ + "error", + "always" ], - "newline-after-var": ["error", "always"], "no-array-constructor": "error", "no-lonely-if": "error", "no-mixed-operators": "off", @@ -191,8 +213,8 @@ "no-multiple-empty-lines": [ "error", { - "max": 1, - }, + "max": 1 + } ], "no-negated-condition": "error", "no-nested-ternary": "error", @@ -205,39 +227,63 @@ "no-whitespace-before-property": "error", "nonblock-statement-body-position": "error", "object-curly-newline": "off", - "object-curly-spacing": ["error", "always"], + "object-curly-spacing": [ + "error", + "always" + ], "object-property-newline": "off", - "padded-blocks": ["error", "never"], + "padded-blocks": [ + "error", + "never" + ], "padding-line-between-statements": [ "error", { "blankLine": "always", "prev": "*", - "next": "return", + "next": "return" }, { "blankLine": "always", - "prev": ["const", "let", "var"], - "next": "*", + "prev": [ + "const", + "let", + "var" + ], + "next": "*" }, { "blankLine": "any", - "prev": ["const", "let", "var"], - "next": ["const", "let", "var"], - }, + "prev": [ + "const", + "let", + "var" + ], + "next": [ + "const", + "let", + "var" + ] + } + ], + "quote-props": [ + "error", + "as-needed" ], - "quote-props": ["error", "as-needed"], "quotes": [ "error", "single", { - "avoidEscape": true, - }, + "avoidEscape": true + } ], - "require-jsdoc": "off", + "require-jsdoc": "warn", "semi": "error", "semi-spacing": "error", - "semi-style": ["error", "last"], + "semi-style": [ + "error", + "last" + ], "sort-keys": "off", "sort-vars": "off", "space-before-blocks": "error", @@ -250,25 +296,28 @@ "always", { "block": { - "exceptions": ["!"], - }, - }, + "exceptions": [ + "!" + ] + } + } ], - "switch-colon-spacing": "error", - }, + "switch-colon-spacing": "error" + } }, { - "files": ["components/logos/*"], + "files": [ + "components/logos/*" + ], "rules": { - "max-len": "off", + "max-len": "off" }, - }, - { + "files": ["scripts/**/*"], "rules": { "import/no-extraneous-dependencies": "off", - "no-console": "off", - }, - }, - ], -} + "no-console": "off" + } + } + ] +} \ No newline at end of file From 599ab9e4914353dbad81354aa04d7abe7e37450f Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Wed, 27 Nov 2024 12:26:33 +0530 Subject: [PATCH 48/59] update rules --- .eslintrc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.eslintrc b/.eslintrc index 176e8dd85088..744817b665f6 100644 --- a/.eslintrc +++ b/.eslintrc @@ -311,13 +311,15 @@ ], "rules": { "max-len": "off" - }, - - "files": ["scripts/**/*"], + } + }, + { + "files": ["scripts/**/*"], "rules": { "import/no-extraneous-dependencies": "off", - "no-console": "off" + "no-console": "off", + "require-jsdoc":"off" } - } + } ] } \ No newline at end of file From e71fcbaf94161c2bcd6624b80d525742290fea2b Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Wed, 27 Nov 2024 12:27:49 +0530 Subject: [PATCH 49/59] change tabs to spaces --- .eslintrc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.eslintrc b/.eslintrc index 744817b665f6..cb6d2cb8a0dd 100644 --- a/.eslintrc +++ b/.eslintrc @@ -313,13 +313,13 @@ "max-len": "off" } }, - { - "files": ["scripts/**/*"], + { + "files": ["scripts/**/*"], "rules": { "import/no-extraneous-dependencies": "off", "no-console": "off", - "require-jsdoc":"off" + "require-jsdoc":"off" } - } + } ] } \ No newline at end of file From 851d1af6bb9a2120938fe31f59cddcd4e6ffc15b Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Wed, 27 Nov 2024 14:25:03 +0530 Subject: [PATCH 50/59] update ts node config --- package-lock.json | 454 +++++++++++++++++++++++++++++++++++++++++++--- package.json | 16 +- tsconfig.json | 1 - 3 files changed, 435 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index e9ab82f13858..56b91aa614b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -78,6 +78,8 @@ "swiper": "^11.0.7", "tailwind-merge": "^2.2.1", "tailwindcss": "^3.4.3", + "ts-node": "^10.9.2", + "tsx": "^4.19.2", "typescript": "^5.3.3", "yaml": "^2.3.4" }, @@ -124,8 +126,7 @@ "remark-cli": "^12.0.1", "remark-lint": "^10.0.0", "remark-mdx": "^3.0.1", - "storybook": "^8.2.4", - "ts-node": "^10.9.2" + "storybook": "^8.2.4" } }, "node_modules/@adobe/css-tools": { @@ -2420,7 +2421,6 @@ "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "devOptional": true, "dependencies": { "@jridgewell/trace-mapping": "0.3.9" }, @@ -2432,7 +2432,6 @@ "version": "0.3.9", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "devOptional": true, "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -2754,6 +2753,21 @@ "node": ">=12" } }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.23.1.tgz", + "integrity": "sha512-3x37szhLexNA4bXhLrCC/LImN/YtWis6WXr1VESlfVtVeoFJBRINPJ3f0a/6LV8zpikqoUg4hyXw0sFBt5Cr+Q==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@esbuild/openbsd-x64": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.20.2.tgz", @@ -7200,26 +7214,22 @@ "node_modules/@tsconfig/node10": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", - "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", - "devOptional": true + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==" }, "node_modules/@tsconfig/node12": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", - "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "devOptional": true + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==" }, "node_modules/@tsconfig/node14": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", - "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "devOptional": true + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==" }, "node_modules/@tsconfig/node16": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", - "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "devOptional": true + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==" }, "node_modules/@types/acorn": { "version": "4.0.6", @@ -10816,8 +10826,7 @@ "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "devOptional": true + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" }, "node_modules/cross-spawn": { "version": "7.0.6", @@ -14682,7 +14691,6 @@ "version": "4.7.5", "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.7.5.tgz", "integrity": "sha512-ZCuZCnlqNzjb4QprAzXKdpp/gh6KTxSJuw3IBsPnV/7fV4NxC9ckB+vPTt8w7fJA0TaSD7c55BR47JD6MEDyDw==", - "dev": true, "dependencies": { "resolve-pkg-maps": "^1.0.0" }, @@ -18338,8 +18346,7 @@ "node_modules/make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "devOptional": true + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" }, "node_modules/makeerror": { "version": "1.0.12", @@ -26281,7 +26288,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", - "dev": true, "funding": { "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" } @@ -28709,7 +28715,6 @@ "version": "10.9.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", - "devOptional": true, "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", @@ -28752,7 +28757,6 @@ "version": "8.14.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", - "devOptional": true, "bin": { "acorn": "bin/acorn" }, @@ -28764,7 +28768,6 @@ "version": "8.3.4", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", - "devOptional": true, "dependencies": { "acorn": "^8.11.0" }, @@ -28775,14 +28778,12 @@ "node_modules/ts-node/node_modules/arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "devOptional": true + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" }, "node_modules/ts-node/node_modules/diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "devOptional": true, "engines": { "node": ">=0.3.1" } @@ -28862,6 +28863,407 @@ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, + "node_modules/tsx": { + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.19.2.tgz", + "integrity": "sha512-pOUl6Vo2LUq/bSa8S5q7b91cgNSjctn9ugq/+Mvow99qW6x/UZYwzxy/3NmqoT66eHYfCVvFvACC58UBPFf28g==", + "dependencies": { + "esbuild": "~0.23.0", + "get-tsconfig": "^4.7.5" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/tsx/node_modules/@esbuild/aix-ppc64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.23.1.tgz", + "integrity": "sha512-6VhYk1diRqrhBAqpJEdjASR/+WVRtfjpqKuNw11cLiaWpAT/Uu+nokB+UJnevzy/P9C/ty6AOe0dwueMrGh/iQ==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-arm": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.23.1.tgz", + "integrity": "sha512-uz6/tEy2IFm9RYOyvKl88zdzZfwEfKZmnX9Cj1BHjeSGNuGLuMD1kR8y5bteYmwqKm1tj8m4cb/aKEorr6fHWQ==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.23.1.tgz", + "integrity": "sha512-xw50ipykXcLstLeWH7WRdQuysJqejuAGPd30vd1i5zSyKK3WE+ijzHmLKxdiCMtH1pHz78rOg0BKSYOSB/2Khw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.23.1.tgz", + "integrity": "sha512-nlN9B69St9BwUoB+jkyU090bru8L0NA3yFvAd7k8dNsVH8bi9a8cUAUSEcEEgTp2z3dbEDGJGfP6VUnkQnlReg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/darwin-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.23.1.tgz", + "integrity": "sha512-YsS2e3Wtgnw7Wq53XXBLcV6JhRsEq8hkfg91ESVadIrzr9wO6jJDMZnCQbHm1Guc5t/CdDiFSSfWP58FNuvT3Q==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/darwin-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.23.1.tgz", + "integrity": "sha512-aClqdgTDVPSEGgoCS8QDG37Gu8yc9lTHNAQlsztQ6ENetKEO//b8y31MMu2ZaPbn4kVsIABzVLXYLhCGekGDqw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/freebsd-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.23.1.tgz", + "integrity": "sha512-h1k6yS8/pN/NHlMl5+v4XPfikhJulk4G+tKGFIOwURBSFzE8bixw1ebjluLOjfwtLqY0kewfjLSrO6tN2MgIhA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/freebsd-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.23.1.tgz", + "integrity": "sha512-lK1eJeyk1ZX8UklqFd/3A60UuZ/6UVfGT2LuGo3Wp4/z7eRTRYY+0xOu2kpClP+vMTi9wKOfXi2vjUpO1Ro76g==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-arm": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.23.1.tgz", + "integrity": "sha512-CXXkzgn+dXAPs3WBwE+Kvnrf4WECwBdfjfeYHpMeVxWE0EceB6vhWGShs6wi0IYEqMSIzdOF1XjQ/Mkm5d7ZdQ==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.23.1.tgz", + "integrity": "sha512-/93bf2yxencYDnItMYV/v116zff6UyTjo4EtEQjUBeGiVpMmffDNUyD9UN2zV+V3LRV3/on4xdZ26NKzn6754g==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-ia32": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.23.1.tgz", + "integrity": "sha512-VTN4EuOHwXEkXzX5nTvVY4s7E/Krz7COC8xkftbbKRYAl96vPiUssGkeMELQMOnLOJ8k3BY1+ZY52tttZnHcXQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-loong64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.23.1.tgz", + "integrity": "sha512-Vx09LzEoBa5zDnieH8LSMRToj7ir/Jeq0Gu6qJ/1GcBq9GkfoEAoXvLiW1U9J1qE/Y/Oyaq33w5p2ZWrNNHNEw==", + "cpu": [ + "loong64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-mips64el": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.23.1.tgz", + "integrity": "sha512-nrFzzMQ7W4WRLNUOU5dlWAqa6yVeI0P78WKGUo7lg2HShq/yx+UYkeNSE0SSfSure0SqgnsxPvmAUu/vu0E+3Q==", + "cpu": [ + "mips64el" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-ppc64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.23.1.tgz", + "integrity": "sha512-dKN8fgVqd0vUIjxuJI6P/9SSSe/mB9rvA98CSH2sJnlZ/OCZWO1DJvxj8jvKTfYUdGfcq2dDxoKaC6bHuTlgcw==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-riscv64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.23.1.tgz", + "integrity": "sha512-5AV4Pzp80fhHL83JM6LoA6pTQVWgB1HovMBsLQ9OZWLDqVY8MVobBXNSmAJi//Csh6tcY7e7Lny2Hg1tElMjIA==", + "cpu": [ + "riscv64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-s390x": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.23.1.tgz", + "integrity": "sha512-9ygs73tuFCe6f6m/Tb+9LtYxWR4c9yg7zjt2cYkjDbDpV/xVn+68cQxMXCjUpYwEkze2RcU/rMnfIXNRFmSoDw==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.23.1.tgz", + "integrity": "sha512-EV6+ovTsEXCPAp58g2dD68LxoP/wK5pRvgy0J/HxPGB009omFPv3Yet0HiaqvrIrgPTBuC6wCH1LTOY91EO5hQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/netbsd-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.23.1.tgz", + "integrity": "sha512-aevEkCNu7KlPRpYLjwmdcuNz6bDFiE7Z8XC4CPqExjTvrHugh28QzUXVOZtiYghciKUacNktqxdpymplil1beA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/openbsd-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.23.1.tgz", + "integrity": "sha512-aY2gMmKmPhxfU+0EdnN+XNtGbjfQgwZj43k8G3fyrDM/UdZww6xrWxmDkuz2eCZchqVeABjV5BpildOrUbBTqA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/sunos-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.23.1.tgz", + "integrity": "sha512-RBRT2gqEl0IKQABT4XTj78tpk9v7ehp+mazn2HbUeZl1YMdaGAQqhapjGTCe7uw7y0frDi4gS0uHzhvpFuI1sA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.23.1.tgz", + "integrity": "sha512-4O+gPR5rEBe2FpKOVyiJ7wNDPA8nGzDuJ6gN4okSA1gEOYZ67N8JPk58tkWtdtPeLz7lBnY6I5L3jdsr3S+A6A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-ia32": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.23.1.tgz", + "integrity": "sha512-BcaL0Vn6QwCwre3Y717nVHZbAa4UBEigzFm6VdsVdT/MbZ38xoj1X9HPkZhbmaBGUD1W8vxAfffbDe8bA6AKnQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.23.1.tgz", + "integrity": "sha512-BHpFFeslkWrXWyUPnbKm+xYYVYruCinGcftSBaa8zoF9hZO4BcSCFUvHVTtzpIY6YzUnYtuEhZ+C9iEXjxnasg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/esbuild": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.23.1.tgz", + "integrity": "sha512-VVNz/9Sa0bs5SELtn3f7qhJCDPCF5oMEl5cO9/SSinpE9hbPVvxbd572HH5AKiP7WD8INO53GgfDDhRjkylHEg==", + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.23.1", + "@esbuild/android-arm": "0.23.1", + "@esbuild/android-arm64": "0.23.1", + "@esbuild/android-x64": "0.23.1", + "@esbuild/darwin-arm64": "0.23.1", + "@esbuild/darwin-x64": "0.23.1", + "@esbuild/freebsd-arm64": "0.23.1", + "@esbuild/freebsd-x64": "0.23.1", + "@esbuild/linux-arm": "0.23.1", + "@esbuild/linux-arm64": "0.23.1", + "@esbuild/linux-ia32": "0.23.1", + "@esbuild/linux-loong64": "0.23.1", + "@esbuild/linux-mips64el": "0.23.1", + "@esbuild/linux-ppc64": "0.23.1", + "@esbuild/linux-riscv64": "0.23.1", + "@esbuild/linux-s390x": "0.23.1", + "@esbuild/linux-x64": "0.23.1", + "@esbuild/netbsd-x64": "0.23.1", + "@esbuild/openbsd-arm64": "0.23.1", + "@esbuild/openbsd-x64": "0.23.1", + "@esbuild/sunos-x64": "0.23.1", + "@esbuild/win32-arm64": "0.23.1", + "@esbuild/win32-ia32": "0.23.1", + "@esbuild/win32-x64": "0.23.1" + } + }, "node_modules/tty-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", @@ -29892,8 +30294,7 @@ "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "devOptional": true + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==" }, "node_modules/v8-to-istanbul": { "version": "9.3.0", @@ -30641,7 +31042,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", - "devOptional": true, "engines": { "node": ">=6" } diff --git a/package.json b/package.json index fc38f85d1729..0f7a3c4748f0 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,10 @@ "dev": "npm run build-scripts && next dev", "build": "npm run build-scripts && next build", "test": "jest --passWithNoTests", - "build:pages": "node --loader ts-node/esm scripts/build-pages.ts && npm run format:mdx", - "build:posts": "node --loader ts-node/esm scripts/index.ts", + "build:pages": "node --loader ts-node/esm --no-warnings=ExperimentalWarning scripts/build-pages.ts && npm run format:mdx", + "build:posts": "node --loader ts-node/esm --no-warnings=ExperimentalWarning scripts/index.ts", "build-scripts": "npm run build:pages && npm run lint:mdx && npm run build:posts", - "write:blog": "node --loader ts-node/esm ./scripts/compose.ts", + "write:blog": "node --loader ts-node/esm --no-warnings=ExperimentalWarning ./scripts/compose.ts", "start": "npx serve@latest out", "export": "next export", "lint": "next lint", @@ -19,12 +19,12 @@ "format:mdx": "prettier --write \"**/*.mdx\"", "lint:mdx": "remark \"**/*.mdx\"", "generate:assets": "echo \"No assets to configure\"", - "generate:meetings": "node --loader ts-node/esm scripts/build-meetings.ts", - "generate:dashboard": "node --loader ts-node/esm scripts/dashboard/build-dashboard.ts", - "generate:videos": "node --loader ts-node/esm scripts/build-newsroom-videos.ts", - "generate:tools": "node --loader ts-node/esm scripts/build-tools.ts", + "generate:meetings": "node --loader ts-node/esm --no-warnings=ExperimentalWarning scripts/build-meetings.ts", + "generate:dashboard": "node --loader ts-node/esm --no-warnings=ExperimentalWarning scripts/dashboard/build-dashboard.ts", + "generate:videos": "node --loader ts-node/esm --no-warnings=ExperimentalWarning scripts/build-newsroom-videos.ts", + "generate:tools": "node --loader ts-node/esm --no-warnings=ExperimentalWarning scripts/build-tools.ts", "test:netlify": "deno test --allow-env --trace-ops netlify/**/*.test.ts", - "test:md": "node --loader ts-node/esm scripts/markdown/check-markdown.ts", + "test:md": "node --loader ts-node/esm --no-warnings=ExperimentalWarning scripts/markdown/check-markdown.ts", "dev:storybook": "storybook dev -p 6006", "build:storybook": "storybook build" }, diff --git a/tsconfig.json b/tsconfig.json index fbc1bc06d441..b73954042008 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,7 +19,6 @@ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.json"], "exclude": ["node_modules", "netlify"], "ts-node": { - "esm": true, "experimentalSpecifierResolution": "node", "transpileOnly": true } From 81d6cfc2af0eec8606cbabda3d599e849f19c40a Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Wed, 27 Nov 2024 16:22:29 +0530 Subject: [PATCH 51/59] migrate tools scripts --- package-lock.json | 454 ++------------------------ scripts/build-tools.ts | 1 + scripts/tools/combine-tools.ts | 4 +- scripts/tools/extract-tools-github.ts | 3 +- scripts/tools/tools-object.ts | 5 +- 5 files changed, 34 insertions(+), 433 deletions(-) diff --git a/package-lock.json b/package-lock.json index 56b91aa614b7..e9ab82f13858 100644 --- a/package-lock.json +++ b/package-lock.json @@ -78,8 +78,6 @@ "swiper": "^11.0.7", "tailwind-merge": "^2.2.1", "tailwindcss": "^3.4.3", - "ts-node": "^10.9.2", - "tsx": "^4.19.2", "typescript": "^5.3.3", "yaml": "^2.3.4" }, @@ -126,7 +124,8 @@ "remark-cli": "^12.0.1", "remark-lint": "^10.0.0", "remark-mdx": "^3.0.1", - "storybook": "^8.2.4" + "storybook": "^8.2.4", + "ts-node": "^10.9.2" } }, "node_modules/@adobe/css-tools": { @@ -2421,6 +2420,7 @@ "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "devOptional": true, "dependencies": { "@jridgewell/trace-mapping": "0.3.9" }, @@ -2432,6 +2432,7 @@ "version": "0.3.9", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "devOptional": true, "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -2753,21 +2754,6 @@ "node": ">=12" } }, - "node_modules/@esbuild/openbsd-arm64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.23.1.tgz", - "integrity": "sha512-3x37szhLexNA4bXhLrCC/LImN/YtWis6WXr1VESlfVtVeoFJBRINPJ3f0a/6LV8zpikqoUg4hyXw0sFBt5Cr+Q==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=18" - } - }, "node_modules/@esbuild/openbsd-x64": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.20.2.tgz", @@ -7214,22 +7200,26 @@ "node_modules/@tsconfig/node10": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", - "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==" + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "devOptional": true }, "node_modules/@tsconfig/node12": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", - "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==" + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "devOptional": true }, "node_modules/@tsconfig/node14": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", - "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==" + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "devOptional": true }, "node_modules/@tsconfig/node16": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", - "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==" + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "devOptional": true }, "node_modules/@types/acorn": { "version": "4.0.6", @@ -10826,7 +10816,8 @@ "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "devOptional": true }, "node_modules/cross-spawn": { "version": "7.0.6", @@ -14691,6 +14682,7 @@ "version": "4.7.5", "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.7.5.tgz", "integrity": "sha512-ZCuZCnlqNzjb4QprAzXKdpp/gh6KTxSJuw3IBsPnV/7fV4NxC9ckB+vPTt8w7fJA0TaSD7c55BR47JD6MEDyDw==", + "dev": true, "dependencies": { "resolve-pkg-maps": "^1.0.0" }, @@ -18346,7 +18338,8 @@ "node_modules/make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "devOptional": true }, "node_modules/makeerror": { "version": "1.0.12", @@ -26288,6 +26281,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, "funding": { "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" } @@ -28715,6 +28709,7 @@ "version": "10.9.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "devOptional": true, "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", @@ -28757,6 +28752,7 @@ "version": "8.14.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", + "devOptional": true, "bin": { "acorn": "bin/acorn" }, @@ -28768,6 +28764,7 @@ "version": "8.3.4", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", + "devOptional": true, "dependencies": { "acorn": "^8.11.0" }, @@ -28778,12 +28775,14 @@ "node_modules/ts-node/node_modules/arg": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "devOptional": true }, "node_modules/ts-node/node_modules/diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "devOptional": true, "engines": { "node": ">=0.3.1" } @@ -28863,407 +28862,6 @@ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, - "node_modules/tsx": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.19.2.tgz", - "integrity": "sha512-pOUl6Vo2LUq/bSa8S5q7b91cgNSjctn9ugq/+Mvow99qW6x/UZYwzxy/3NmqoT66eHYfCVvFvACC58UBPFf28g==", - "dependencies": { - "esbuild": "~0.23.0", - "get-tsconfig": "^4.7.5" - }, - "bin": { - "tsx": "dist/cli.mjs" - }, - "engines": { - "node": ">=18.0.0" - }, - "optionalDependencies": { - "fsevents": "~2.3.3" - } - }, - "node_modules/tsx/node_modules/@esbuild/aix-ppc64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.23.1.tgz", - "integrity": "sha512-6VhYk1diRqrhBAqpJEdjASR/+WVRtfjpqKuNw11cLiaWpAT/Uu+nokB+UJnevzy/P9C/ty6AOe0dwueMrGh/iQ==", - "cpu": [ - "ppc64" - ], - "optional": true, - "os": [ - "aix" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/android-arm": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.23.1.tgz", - "integrity": "sha512-uz6/tEy2IFm9RYOyvKl88zdzZfwEfKZmnX9Cj1BHjeSGNuGLuMD1kR8y5bteYmwqKm1tj8m4cb/aKEorr6fHWQ==", - "cpu": [ - "arm" - ], - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/android-arm64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.23.1.tgz", - "integrity": "sha512-xw50ipykXcLstLeWH7WRdQuysJqejuAGPd30vd1i5zSyKK3WE+ijzHmLKxdiCMtH1pHz78rOg0BKSYOSB/2Khw==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/android-x64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.23.1.tgz", - "integrity": "sha512-nlN9B69St9BwUoB+jkyU090bru8L0NA3yFvAd7k8dNsVH8bi9a8cUAUSEcEEgTp2z3dbEDGJGfP6VUnkQnlReg==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/darwin-arm64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.23.1.tgz", - "integrity": "sha512-YsS2e3Wtgnw7Wq53XXBLcV6JhRsEq8hkfg91ESVadIrzr9wO6jJDMZnCQbHm1Guc5t/CdDiFSSfWP58FNuvT3Q==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/darwin-x64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.23.1.tgz", - "integrity": "sha512-aClqdgTDVPSEGgoCS8QDG37Gu8yc9lTHNAQlsztQ6ENetKEO//b8y31MMu2ZaPbn4kVsIABzVLXYLhCGekGDqw==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/freebsd-arm64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.23.1.tgz", - "integrity": "sha512-h1k6yS8/pN/NHlMl5+v4XPfikhJulk4G+tKGFIOwURBSFzE8bixw1ebjluLOjfwtLqY0kewfjLSrO6tN2MgIhA==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/freebsd-x64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.23.1.tgz", - "integrity": "sha512-lK1eJeyk1ZX8UklqFd/3A60UuZ/6UVfGT2LuGo3Wp4/z7eRTRYY+0xOu2kpClP+vMTi9wKOfXi2vjUpO1Ro76g==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-arm": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.23.1.tgz", - "integrity": "sha512-CXXkzgn+dXAPs3WBwE+Kvnrf4WECwBdfjfeYHpMeVxWE0EceB6vhWGShs6wi0IYEqMSIzdOF1XjQ/Mkm5d7ZdQ==", - "cpu": [ - "arm" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-arm64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.23.1.tgz", - "integrity": "sha512-/93bf2yxencYDnItMYV/v116zff6UyTjo4EtEQjUBeGiVpMmffDNUyD9UN2zV+V3LRV3/on4xdZ26NKzn6754g==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-ia32": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.23.1.tgz", - "integrity": "sha512-VTN4EuOHwXEkXzX5nTvVY4s7E/Krz7COC8xkftbbKRYAl96vPiUssGkeMELQMOnLOJ8k3BY1+ZY52tttZnHcXQ==", - "cpu": [ - "ia32" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-loong64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.23.1.tgz", - "integrity": "sha512-Vx09LzEoBa5zDnieH8LSMRToj7ir/Jeq0Gu6qJ/1GcBq9GkfoEAoXvLiW1U9J1qE/Y/Oyaq33w5p2ZWrNNHNEw==", - "cpu": [ - "loong64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-mips64el": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.23.1.tgz", - "integrity": "sha512-nrFzzMQ7W4WRLNUOU5dlWAqa6yVeI0P78WKGUo7lg2HShq/yx+UYkeNSE0SSfSure0SqgnsxPvmAUu/vu0E+3Q==", - "cpu": [ - "mips64el" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-ppc64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.23.1.tgz", - "integrity": "sha512-dKN8fgVqd0vUIjxuJI6P/9SSSe/mB9rvA98CSH2sJnlZ/OCZWO1DJvxj8jvKTfYUdGfcq2dDxoKaC6bHuTlgcw==", - "cpu": [ - "ppc64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-riscv64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.23.1.tgz", - "integrity": "sha512-5AV4Pzp80fhHL83JM6LoA6pTQVWgB1HovMBsLQ9OZWLDqVY8MVobBXNSmAJi//Csh6tcY7e7Lny2Hg1tElMjIA==", - "cpu": [ - "riscv64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-s390x": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.23.1.tgz", - "integrity": "sha512-9ygs73tuFCe6f6m/Tb+9LtYxWR4c9yg7zjt2cYkjDbDpV/xVn+68cQxMXCjUpYwEkze2RcU/rMnfIXNRFmSoDw==", - "cpu": [ - "s390x" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/linux-x64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.23.1.tgz", - "integrity": "sha512-EV6+ovTsEXCPAp58g2dD68LxoP/wK5pRvgy0J/HxPGB009omFPv3Yet0HiaqvrIrgPTBuC6wCH1LTOY91EO5hQ==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/netbsd-x64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.23.1.tgz", - "integrity": "sha512-aevEkCNu7KlPRpYLjwmdcuNz6bDFiE7Z8XC4CPqExjTvrHugh28QzUXVOZtiYghciKUacNktqxdpymplil1beA==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/openbsd-x64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.23.1.tgz", - "integrity": "sha512-aY2gMmKmPhxfU+0EdnN+XNtGbjfQgwZj43k8G3fyrDM/UdZww6xrWxmDkuz2eCZchqVeABjV5BpildOrUbBTqA==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/sunos-x64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.23.1.tgz", - "integrity": "sha512-RBRT2gqEl0IKQABT4XTj78tpk9v7ehp+mazn2HbUeZl1YMdaGAQqhapjGTCe7uw7y0frDi4gS0uHzhvpFuI1sA==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/win32-arm64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.23.1.tgz", - "integrity": "sha512-4O+gPR5rEBe2FpKOVyiJ7wNDPA8nGzDuJ6gN4okSA1gEOYZ67N8JPk58tkWtdtPeLz7lBnY6I5L3jdsr3S+A6A==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/win32-ia32": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.23.1.tgz", - "integrity": "sha512-BcaL0Vn6QwCwre3Y717nVHZbAa4UBEigzFm6VdsVdT/MbZ38xoj1X9HPkZhbmaBGUD1W8vxAfffbDe8bA6AKnQ==", - "cpu": [ - "ia32" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/@esbuild/win32-x64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.23.1.tgz", - "integrity": "sha512-BHpFFeslkWrXWyUPnbKm+xYYVYruCinGcftSBaa8zoF9hZO4BcSCFUvHVTtzpIY6YzUnYtuEhZ+C9iEXjxnasg==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/tsx/node_modules/esbuild": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.23.1.tgz", - "integrity": "sha512-VVNz/9Sa0bs5SELtn3f7qhJCDPCF5oMEl5cO9/SSinpE9hbPVvxbd572HH5AKiP7WD8INO53GgfDDhRjkylHEg==", - "hasInstallScript": true, - "bin": { - "esbuild": "bin/esbuild" - }, - "engines": { - "node": ">=18" - }, - "optionalDependencies": { - "@esbuild/aix-ppc64": "0.23.1", - "@esbuild/android-arm": "0.23.1", - "@esbuild/android-arm64": "0.23.1", - "@esbuild/android-x64": "0.23.1", - "@esbuild/darwin-arm64": "0.23.1", - "@esbuild/darwin-x64": "0.23.1", - "@esbuild/freebsd-arm64": "0.23.1", - "@esbuild/freebsd-x64": "0.23.1", - "@esbuild/linux-arm": "0.23.1", - "@esbuild/linux-arm64": "0.23.1", - "@esbuild/linux-ia32": "0.23.1", - "@esbuild/linux-loong64": "0.23.1", - "@esbuild/linux-mips64el": "0.23.1", - "@esbuild/linux-ppc64": "0.23.1", - "@esbuild/linux-riscv64": "0.23.1", - "@esbuild/linux-s390x": "0.23.1", - "@esbuild/linux-x64": "0.23.1", - "@esbuild/netbsd-x64": "0.23.1", - "@esbuild/openbsd-arm64": "0.23.1", - "@esbuild/openbsd-x64": "0.23.1", - "@esbuild/sunos-x64": "0.23.1", - "@esbuild/win32-arm64": "0.23.1", - "@esbuild/win32-ia32": "0.23.1", - "@esbuild/win32-x64": "0.23.1" - } - }, "node_modules/tty-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", @@ -30294,7 +29892,8 @@ "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==" + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "devOptional": true }, "node_modules/v8-to-istanbul": { "version": "9.3.0", @@ -31042,6 +30641,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "devOptional": true, "engines": { "node": ">=6" } diff --git a/scripts/build-tools.ts b/scripts/build-tools.ts index 114d481cc0a5..9dfb88f12e80 100644 --- a/scripts/build-tools.ts +++ b/scripts/build-tools.ts @@ -13,6 +13,7 @@ const buildTools = async (automatedToolsPath: string, manualToolsPath: string, t await fs.writeFile(automatedToolsPath, JSON.stringify(automatedTools, null, ' ')); + // eslint-disable-next-line import/no-dynamic-require, global-require await combineTools(automatedTools, require(manualToolsPath), toolsPath, tagsPath); } catch (err) { assert(err instanceof Error); diff --git a/scripts/tools/combine-tools.ts b/scripts/tools/combine-tools.ts index 60f984cf1a0e..1a98de91ebde 100644 --- a/scripts/tools/combine-tools.ts +++ b/scripts/tools/combine-tools.ts @@ -1,12 +1,12 @@ import Ajv from 'ajv'; import addFormats from 'ajv-formats'; import fs from 'fs'; -import Fuse from 'fuse'; +import Fuse from 'fuse.js'; import { categoryList } from './categorylist'; import { languagesColor, technologiesColor } from './tags-color'; import { createToolObject } from './tools-object'; -import schema from './tools-schema.json'; +import schema from './tools-schema.json' assert { type: 'json' }; const ajv = new Ajv(); diff --git a/scripts/tools/extract-tools-github.ts b/scripts/tools/extract-tools-github.ts index 71a2a8cbb1f6..7b9831dfd67c 100644 --- a/scripts/tools/extract-tools-github.ts +++ b/scripts/tools/extract-tools-github.ts @@ -1,6 +1,7 @@ import axios from 'axios'; +import dotenv from 'dotenv'; -require('dotenv').config(); +dotenv.config(); const getData = async () => { try { diff --git a/scripts/tools/tools-object.ts b/scripts/tools/tools-object.ts index 5482daa91898..d7bb1f8b9e86 100644 --- a/scripts/tools/tools-object.ts +++ b/scripts/tools/tools-object.ts @@ -5,7 +5,7 @@ import Fuse from 'fuse.js'; import { convertToJson } from '../utils'; import { categoryList } from './categorylist'; -import schema from './tools-schema.json'; +import schema from './tools-schema.json' assert { type: 'json' }; const ajv = new Ajv(); @@ -56,8 +56,7 @@ async function convertTools(data) { // initialising finalToolsObject with all categories inside it with proper elements in each category for (const index in categoryList) { finalToolsObject[categoryList[index].name] = { - description: categoryList[index].description, - toolsList: [] + description: categoryList[index].de }; } From c5b5c9ffa8f980b73c3e6d350bc688543ee6b8be Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Wed, 27 Nov 2024 16:30:22 +0530 Subject: [PATCH 52/59] refactor __dirname variable --- scripts/build-tools.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/build-tools.ts b/scripts/build-tools.ts index 9dfb88f12e80..72a0fa2b4af0 100644 --- a/scripts/build-tools.ts +++ b/scripts/build-tools.ts @@ -1,11 +1,15 @@ import assert from 'assert'; import fs from 'fs-extra'; -import { resolve } from 'path'; +import { dirname, resolve } from 'path'; +import { fileURLToPath } from 'url'; import { combineTools } from './tools/combine-tools'; import { getData } from './tools/extract-tools-github'; import { convertTools } from './tools/tools-object'; +const currentFilePath = fileURLToPath(import.meta.url); +const currentDirPath = dirname(currentFilePath); + const buildTools = async (automatedToolsPath: string, manualToolsPath: string, toolsPath: string, tagsPath: string) => { try { const githubExtractData = await getData(); @@ -22,11 +26,11 @@ const buildTools = async (automatedToolsPath: string, manualToolsPath: string, t }; /* istanbul ignore next */ -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'); +if (process.argv[1] === fileURLToPath(import.meta.url)) { + 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'); buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath); } From a42104e2f801c061c903b4d30df7e303df3321d6 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Wed, 27 Nov 2024 16:34:19 +0530 Subject: [PATCH 53/59] refactor function in build-rss --- scripts/build-rss.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/build-rss.ts b/scripts/build-rss.ts index 9eda115bc4d7..51fe12483963 100644 --- a/scripts/build-rss.ts +++ b/scripts/build-rss.ts @@ -7,15 +7,17 @@ async function getAllPosts() { return posts; } -function clean(s) { - s = s.split('<span>').join(''); - s = s.split('&').join('&'); - s = s.split(''').join("'"); - s = s.split('<').join('<'); - s = s.split('>').join('>'); - s = s.split('"').join('"'); - - return s; +function clean(s: string) { + let cleanS = s; + + cleanS = cleanS.split('<span>').join(''); + cleanS = cleanS.split('&').join('&'); + cleanS = cleanS.split(''').join("'"); + cleanS = cleanS.split('<').join('<'); + cleanS = cleanS.split('>').join('>'); + cleanS = cleanS.split('"').join('"'); + + return cleanS; } export async function rssFeed(type, title, desc, outputPath) { From add1c284b08084a51cce16363dec233b641784f9 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Wed, 27 Nov 2024 16:36:20 +0530 Subject: [PATCH 54/59] add new package type --- types/packages/jgexml__json2xml.d.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 types/packages/jgexml__json2xml.d.ts diff --git a/types/packages/jgexml__json2xml.d.ts b/types/packages/jgexml__json2xml.d.ts new file mode 100644 index 000000000000..7c5bd65dce9c --- /dev/null +++ b/types/packages/jgexml__json2xml.d.ts @@ -0,0 +1,9 @@ +declare module 'jgexml/json2xml' { + interface Json2Xml { + getXml(feed: unknown, attributePrefix: string, defaultValue: string, indentLevel: number): string; + } + + const json2xml: Json2Xml; + + export = json2xml; +} From b776dc76ecf454d2edc3b3ce92f52b69c4bc02f1 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Wed, 27 Nov 2024 16:59:52 +0530 Subject: [PATCH 55/59] Added error handling for undefined types --- scripts/build-meetings.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/build-meetings.ts b/scripts/build-meetings.ts index 68a810704fd8..30feba8a3dd7 100644 --- a/scripts/build-meetings.ts +++ b/scripts/build-meetings.ts @@ -1,8 +1,9 @@ +import assert from 'assert'; import { writeFileSync } from 'fs'; import { google } from 'googleapis'; import { resolve } from 'path'; -async function buildMeetings(writePath) { +async function buildMeetings(writePath: string) { let auth; let calendar; @@ -14,6 +15,7 @@ async function buildMeetings(writePath) { calendar = google.calendar({ version: 'v3', auth }); } catch (err) { + assert(err instanceof Error); throw new Error(`Authentication failed: ${err.message}`); } @@ -31,7 +33,16 @@ async function buildMeetings(writePath) { timeMin }); + // check if the response is valid and not undefined + if (!eventsList.data.items || !Array.isArray(eventsList.data.items)) { + throw new Error('Invalid data structure received from Google Calendar API'); + } + eventsItems = eventsList.data.items.map((e) => { + if (!e.start || !e.start.dateTime) { + throw new Error('start.dateTime is missing in the event'); + } + return { title: e.summary, calLink: e.htmlLink, @@ -49,6 +60,7 @@ async function buildMeetings(writePath) { writeFileSync(writePath, eventsForHuman); } catch (err) { + assert(err instanceof Error); throw new Error(`Failed to fetch or process events: ${err.message}`); } } From 5b82b5dc4dd62de354a940ad78b34ff485adde45 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Wed, 27 Nov 2024 17:05:48 +0530 Subject: [PATCH 56/59] add types --- scripts/utils/readAndWriteJson.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/utils/readAndWriteJson.ts b/scripts/utils/readAndWriteJson.ts index 0b8721a8379b..6e5e65a17a5e 100644 --- a/scripts/utils/readAndWriteJson.ts +++ b/scripts/utils/readAndWriteJson.ts @@ -2,7 +2,7 @@ import { readFile, writeFile } from 'fs/promises'; import { convertToJson } from '../utils'; -export async function writeJSON(readPath, writePath) { +export async function writeJSON(readPath: string, writePath: string) { let readContent; let jsonContent; From 0916549c84c7f84fc317c2d258cd341143962ca7 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Wed, 27 Nov 2024 17:12:37 +0530 Subject: [PATCH 57/59] refactor adopter/index.ts --- scripts/adopters/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/adopters/index.ts b/scripts/adopters/index.ts index 0e6b9ecfa888..c7307049bf59 100644 --- a/scripts/adopters/index.ts +++ b/scripts/adopters/index.ts @@ -3,7 +3,6 @@ import { fileURLToPath } from 'url'; import { writeJSON } from '../utils/readAndWriteJson'; - const currentFilePath = fileURLToPath(import.meta.url); const currentDirPath = dirname(currentFilePath); From ba0a99a8a55b8be5dce384f850cf2adcc6e8134c Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 12 Dec 2024 16:09:28 +0530 Subject: [PATCH 58/59] use tsx instead of ts-node --- package-lock.json | 467 ++++++++++++++++++++++++++++++++++++++++++++-- package.json | 20 +- 2 files changed, 458 insertions(+), 29 deletions(-) diff --git a/package-lock.json b/package-lock.json index c6f5f8d96d3e..3d2a04d88f4e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -78,6 +78,7 @@ "swiper": "^11.0.7", "tailwind-merge": "^2.2.1", "tailwindcss": "^3.4.3", + "tsx": "^4.19.2", "typescript": "^5.3.3", "yaml": "^2.3.4" }, @@ -124,8 +125,7 @@ "remark-cli": "^12.0.1", "remark-lint": "^10.0.0", "remark-mdx": "^3.0.1", - "storybook": "^8.2.4", - "ts-node": "^10.9.2" + "storybook": "^8.2.4" } }, "node_modules/@adobe/css-tools": { @@ -2420,7 +2420,8 @@ "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "@jridgewell/trace-mapping": "0.3.9" }, @@ -2432,7 +2433,8 @@ "version": "0.3.9", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -2754,6 +2756,21 @@ "node": ">=12" } }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.23.1.tgz", + "integrity": "sha512-3x37szhLexNA4bXhLrCC/LImN/YtWis6WXr1VESlfVtVeoFJBRINPJ3f0a/6LV8zpikqoUg4hyXw0sFBt5Cr+Q==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@esbuild/openbsd-x64": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.20.2.tgz", @@ -7201,25 +7218,29 @@ "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/@tsconfig/node12": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/@tsconfig/node14": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/@tsconfig/node16": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/@types/acorn": { "version": "4.0.6", @@ -10817,7 +10838,8 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/cross-spawn": { "version": "7.0.6", @@ -14686,7 +14708,6 @@ "version": "4.7.5", "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.7.5.tgz", "integrity": "sha512-ZCuZCnlqNzjb4QprAzXKdpp/gh6KTxSJuw3IBsPnV/7fV4NxC9ckB+vPTt8w7fJA0TaSD7c55BR47JD6MEDyDw==", - "dev": true, "dependencies": { "resolve-pkg-maps": "^1.0.0" }, @@ -18343,7 +18364,8 @@ "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/makeerror": { "version": "1.0.12", @@ -26285,7 +26307,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", - "dev": true, "funding": { "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" } @@ -28713,7 +28734,8 @@ "version": "10.9.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", @@ -28756,7 +28778,8 @@ "version": "8.14.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", - "devOptional": true, + "optional": true, + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -28768,7 +28791,8 @@ "version": "8.3.4", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "acorn": "^8.11.0" }, @@ -28780,13 +28804,15 @@ "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/ts-node/node_modules/diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=0.3.1" } @@ -28866,6 +28892,407 @@ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, + "node_modules/tsx": { + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.19.2.tgz", + "integrity": "sha512-pOUl6Vo2LUq/bSa8S5q7b91cgNSjctn9ugq/+Mvow99qW6x/UZYwzxy/3NmqoT66eHYfCVvFvACC58UBPFf28g==", + "dependencies": { + "esbuild": "~0.23.0", + "get-tsconfig": "^4.7.5" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/tsx/node_modules/@esbuild/aix-ppc64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.23.1.tgz", + "integrity": "sha512-6VhYk1diRqrhBAqpJEdjASR/+WVRtfjpqKuNw11cLiaWpAT/Uu+nokB+UJnevzy/P9C/ty6AOe0dwueMrGh/iQ==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-arm": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.23.1.tgz", + "integrity": "sha512-uz6/tEy2IFm9RYOyvKl88zdzZfwEfKZmnX9Cj1BHjeSGNuGLuMD1kR8y5bteYmwqKm1tj8m4cb/aKEorr6fHWQ==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.23.1.tgz", + "integrity": "sha512-xw50ipykXcLstLeWH7WRdQuysJqejuAGPd30vd1i5zSyKK3WE+ijzHmLKxdiCMtH1pHz78rOg0BKSYOSB/2Khw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.23.1.tgz", + "integrity": "sha512-nlN9B69St9BwUoB+jkyU090bru8L0NA3yFvAd7k8dNsVH8bi9a8cUAUSEcEEgTp2z3dbEDGJGfP6VUnkQnlReg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/darwin-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.23.1.tgz", + "integrity": "sha512-YsS2e3Wtgnw7Wq53XXBLcV6JhRsEq8hkfg91ESVadIrzr9wO6jJDMZnCQbHm1Guc5t/CdDiFSSfWP58FNuvT3Q==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/darwin-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.23.1.tgz", + "integrity": "sha512-aClqdgTDVPSEGgoCS8QDG37Gu8yc9lTHNAQlsztQ6ENetKEO//b8y31MMu2ZaPbn4kVsIABzVLXYLhCGekGDqw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/freebsd-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.23.1.tgz", + "integrity": "sha512-h1k6yS8/pN/NHlMl5+v4XPfikhJulk4G+tKGFIOwURBSFzE8bixw1ebjluLOjfwtLqY0kewfjLSrO6tN2MgIhA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/freebsd-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.23.1.tgz", + "integrity": "sha512-lK1eJeyk1ZX8UklqFd/3A60UuZ/6UVfGT2LuGo3Wp4/z7eRTRYY+0xOu2kpClP+vMTi9wKOfXi2vjUpO1Ro76g==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-arm": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.23.1.tgz", + "integrity": "sha512-CXXkzgn+dXAPs3WBwE+Kvnrf4WECwBdfjfeYHpMeVxWE0EceB6vhWGShs6wi0IYEqMSIzdOF1XjQ/Mkm5d7ZdQ==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.23.1.tgz", + "integrity": "sha512-/93bf2yxencYDnItMYV/v116zff6UyTjo4EtEQjUBeGiVpMmffDNUyD9UN2zV+V3LRV3/on4xdZ26NKzn6754g==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-ia32": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.23.1.tgz", + "integrity": "sha512-VTN4EuOHwXEkXzX5nTvVY4s7E/Krz7COC8xkftbbKRYAl96vPiUssGkeMELQMOnLOJ8k3BY1+ZY52tttZnHcXQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-loong64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.23.1.tgz", + "integrity": "sha512-Vx09LzEoBa5zDnieH8LSMRToj7ir/Jeq0Gu6qJ/1GcBq9GkfoEAoXvLiW1U9J1qE/Y/Oyaq33w5p2ZWrNNHNEw==", + "cpu": [ + "loong64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-mips64el": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.23.1.tgz", + "integrity": "sha512-nrFzzMQ7W4WRLNUOU5dlWAqa6yVeI0P78WKGUo7lg2HShq/yx+UYkeNSE0SSfSure0SqgnsxPvmAUu/vu0E+3Q==", + "cpu": [ + "mips64el" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-ppc64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.23.1.tgz", + "integrity": "sha512-dKN8fgVqd0vUIjxuJI6P/9SSSe/mB9rvA98CSH2sJnlZ/OCZWO1DJvxj8jvKTfYUdGfcq2dDxoKaC6bHuTlgcw==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-riscv64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.23.1.tgz", + "integrity": "sha512-5AV4Pzp80fhHL83JM6LoA6pTQVWgB1HovMBsLQ9OZWLDqVY8MVobBXNSmAJi//Csh6tcY7e7Lny2Hg1tElMjIA==", + "cpu": [ + "riscv64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-s390x": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.23.1.tgz", + "integrity": "sha512-9ygs73tuFCe6f6m/Tb+9LtYxWR4c9yg7zjt2cYkjDbDpV/xVn+68cQxMXCjUpYwEkze2RcU/rMnfIXNRFmSoDw==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.23.1.tgz", + "integrity": "sha512-EV6+ovTsEXCPAp58g2dD68LxoP/wK5pRvgy0J/HxPGB009omFPv3Yet0HiaqvrIrgPTBuC6wCH1LTOY91EO5hQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/netbsd-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.23.1.tgz", + "integrity": "sha512-aevEkCNu7KlPRpYLjwmdcuNz6bDFiE7Z8XC4CPqExjTvrHugh28QzUXVOZtiYghciKUacNktqxdpymplil1beA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/openbsd-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.23.1.tgz", + "integrity": "sha512-aY2gMmKmPhxfU+0EdnN+XNtGbjfQgwZj43k8G3fyrDM/UdZww6xrWxmDkuz2eCZchqVeABjV5BpildOrUbBTqA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/sunos-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.23.1.tgz", + "integrity": "sha512-RBRT2gqEl0IKQABT4XTj78tpk9v7ehp+mazn2HbUeZl1YMdaGAQqhapjGTCe7uw7y0frDi4gS0uHzhvpFuI1sA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.23.1.tgz", + "integrity": "sha512-4O+gPR5rEBe2FpKOVyiJ7wNDPA8nGzDuJ6gN4okSA1gEOYZ67N8JPk58tkWtdtPeLz7lBnY6I5L3jdsr3S+A6A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-ia32": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.23.1.tgz", + "integrity": "sha512-BcaL0Vn6QwCwre3Y717nVHZbAa4UBEigzFm6VdsVdT/MbZ38xoj1X9HPkZhbmaBGUD1W8vxAfffbDe8bA6AKnQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.23.1.tgz", + "integrity": "sha512-BHpFFeslkWrXWyUPnbKm+xYYVYruCinGcftSBaa8zoF9hZO4BcSCFUvHVTtzpIY6YzUnYtuEhZ+C9iEXjxnasg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/esbuild": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.23.1.tgz", + "integrity": "sha512-VVNz/9Sa0bs5SELtn3f7qhJCDPCF5oMEl5cO9/SSinpE9hbPVvxbd572HH5AKiP7WD8INO53GgfDDhRjkylHEg==", + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.23.1", + "@esbuild/android-arm": "0.23.1", + "@esbuild/android-arm64": "0.23.1", + "@esbuild/android-x64": "0.23.1", + "@esbuild/darwin-arm64": "0.23.1", + "@esbuild/darwin-x64": "0.23.1", + "@esbuild/freebsd-arm64": "0.23.1", + "@esbuild/freebsd-x64": "0.23.1", + "@esbuild/linux-arm": "0.23.1", + "@esbuild/linux-arm64": "0.23.1", + "@esbuild/linux-ia32": "0.23.1", + "@esbuild/linux-loong64": "0.23.1", + "@esbuild/linux-mips64el": "0.23.1", + "@esbuild/linux-ppc64": "0.23.1", + "@esbuild/linux-riscv64": "0.23.1", + "@esbuild/linux-s390x": "0.23.1", + "@esbuild/linux-x64": "0.23.1", + "@esbuild/netbsd-x64": "0.23.1", + "@esbuild/openbsd-arm64": "0.23.1", + "@esbuild/openbsd-x64": "0.23.1", + "@esbuild/sunos-x64": "0.23.1", + "@esbuild/win32-arm64": "0.23.1", + "@esbuild/win32-ia32": "0.23.1", + "@esbuild/win32-x64": "0.23.1" + } + }, "node_modules/tty-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", @@ -29897,7 +30324,8 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/v8-to-istanbul": { "version": "9.3.0", @@ -30645,7 +31073,8 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", - "devOptional": true, + "optional": true, + "peer": true, "engines": { "node": ">=6" } diff --git a/package.json b/package.json index 0f7a3c4748f0..92ece21c0c9f 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,10 @@ "dev": "npm run build-scripts && next dev", "build": "npm run build-scripts && next build", "test": "jest --passWithNoTests", - "build:pages": "node --loader ts-node/esm --no-warnings=ExperimentalWarning scripts/build-pages.ts && npm run format:mdx", - "build:posts": "node --loader ts-node/esm --no-warnings=ExperimentalWarning scripts/index.ts", + "build:pages": "tsx scripts/build-pages.ts && npm run format:mdx", + "build:posts": "tsx scripts/index.ts", "build-scripts": "npm run build:pages && npm run lint:mdx && npm run build:posts", - "write:blog": "node --loader ts-node/esm --no-warnings=ExperimentalWarning ./scripts/compose.ts", + "write:blog": "tsx ./scripts/compose.ts", "start": "npx serve@latest out", "export": "next export", "lint": "next lint", @@ -19,12 +19,12 @@ "format:mdx": "prettier --write \"**/*.mdx\"", "lint:mdx": "remark \"**/*.mdx\"", "generate:assets": "echo \"No assets to configure\"", - "generate:meetings": "node --loader ts-node/esm --no-warnings=ExperimentalWarning scripts/build-meetings.ts", - "generate:dashboard": "node --loader ts-node/esm --no-warnings=ExperimentalWarning scripts/dashboard/build-dashboard.ts", - "generate:videos": "node --loader ts-node/esm --no-warnings=ExperimentalWarning scripts/build-newsroom-videos.ts", - "generate:tools": "node --loader ts-node/esm --no-warnings=ExperimentalWarning scripts/build-tools.ts", + "generate:meetings": "tsx scripts/build-meetings.ts", + "generate:dashboard": "tsx scripts/dashboard/build-dashboard.ts", + "generate:videos": "tsx scripts/build-newsroom-videos.ts", + "generate:tools": "tsx scripts/build-tools.ts", "test:netlify": "deno test --allow-env --trace-ops netlify/**/*.test.ts", - "test:md": "node --loader ts-node/esm --no-warnings=ExperimentalWarning scripts/markdown/check-markdown.ts", + "test:md": "tsx scripts/markdown/check-markdown.ts", "dev:storybook": "storybook dev -p 6006", "build:storybook": "storybook build" }, @@ -115,6 +115,7 @@ "swiper": "^11.0.7", "tailwind-merge": "^2.2.1", "tailwindcss": "^3.4.3", + "tsx": "^4.19.2", "typescript": "^5.3.3", "yaml": "^2.3.4" }, @@ -161,7 +162,6 @@ "remark-cli": "^12.0.1", "remark-lint": "^10.0.0", "remark-mdx": "^3.0.1", - "storybook": "^8.2.4", - "ts-node": "^10.9.2" + "storybook": "^8.2.4" } } From c76a556d5d4d31f1830436f66de5cb6cfbf04a1f Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Thu, 12 Dec 2024 17:27:12 +0530 Subject: [PATCH 59/59] add types for build RSS --- scripts/build-rss.ts | 29 ++++++++++++++++++----------- types/scripts/build-rss.ts | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 types/scripts/build-rss.ts diff --git a/scripts/build-rss.ts b/scripts/build-rss.ts index 51fe12483963..28298b7bb7e6 100644 --- a/scripts/build-rss.ts +++ b/scripts/build-rss.ts @@ -1,6 +1,9 @@ +import assert from 'assert'; import fs from 'fs/promises'; import json2xml from 'jgexml/json2xml'; +import type { BlogPostTypes, Enclosure, RSS, RSSItemType } from '@/types/scripts/build-rss'; + async function getAllPosts() { const posts = (await import('../config/posts.json', { assert: { type: 'json' } })).default; @@ -20,9 +23,9 @@ function clean(s: string) { return cleanS; } -export async function rssFeed(type, title, desc, outputPath) { +export async function rssFeed(type: BlogPostTypes, rssTitle: string, desc: string, outputPath: string) { try { - let posts = (await getAllPosts())[`${type}`]; + let posts = (await getAllPosts())[`${type}`] as any[]; const missingDatePosts = posts.filter((post) => !post.date); posts = posts.filter((post) => post.date); @@ -33,7 +36,7 @@ export async function rssFeed(type, title, desc, outputPath) { if (i1.featured && !i2.featured) return -1; if (!i1.featured && i2.featured) return 1; - return i2Date - i1Date; + return i2Date.getTime() - i1Date.getTime(); }); if (missingDatePosts.length > 0) { @@ -43,15 +46,15 @@ export async function rssFeed(type, title, desc, outputPath) { const base = 'https://www.asyncapi.com'; const tracking = '?utm_source=rss'; - const feed = {}; - const rss = {}; + const feed = {} as { rss: RSS }; + const rss = {} as RSS; rss['@version'] = '2.0'; rss['@xmlns:atom'] = 'http://www.w3.org/2005/Atom'; - rss.channel = {}; - rss.channel.title = title; + rss.channel = {} as RSS['channel']; + rss.channel.title = rssTitle; rss.channel.link = `${base}/${outputPath}`; - rss.channel['atom:link'] = {}; + rss.channel['atom:link'] = {} as RSS['channel']['atom:link']; rss.channel['atom:link']['@rel'] = 'self'; rss.channel['atom:link']['@href'] = rss.channel.link; rss.channel['atom:link']['@type'] = 'application/rss+xml'; @@ -75,17 +78,17 @@ export async function rssFeed(type, title, desc, outputPath) { const pubDate = new Date(date).toUTCString(); const description = clean(excerpt); const guid = { '@isPermaLink': true, '': link }; - const item = { + const item: RSSItemType = { title, description, link, category: type, guid, pubDate - }; + } as RSSItemType; if (post.cover) { - const enclosure = {}; + const enclosure = {} as Enclosure; enclosure['@url'] = base + post.cover; enclosure['@length'] = 15026; // dummy value, anything works @@ -93,8 +96,11 @@ export async function rssFeed(type, title, desc, outputPath) { if (typeof enclosure['@url'] === 'string') { const tmp = enclosure['@url'].toLowerCase(); + // eslint-disable-next-line max-depth if (tmp.indexOf('.png') >= 0) enclosure['@type'] = 'image/png'; + // eslint-disable-next-line max-depth if (tmp.indexOf('.svg') >= 0) enclosure['@type'] = 'image/svg+xml'; + // eslint-disable-next-line max-depth if (tmp.indexOf('.webp') >= 0) enclosure['@type'] = 'image/webp'; } item.enclosure = enclosure; @@ -108,6 +114,7 @@ export async function rssFeed(type, title, desc, outputPath) { await fs.writeFile(`./public/${outputPath}`, xml, 'utf8'); } catch (err) { + assert(err instanceof Error); throw new Error(`Failed to generate RSS feed: ${err.message}`); } } diff --git a/types/scripts/build-rss.ts b/types/scripts/build-rss.ts new file mode 100644 index 000000000000..3780fdbb0453 --- /dev/null +++ b/types/scripts/build-rss.ts @@ -0,0 +1,37 @@ +export type BlogPostTypes = 'docs' | 'blog' | 'about' | 'docsTree'; +export type Enclosure = { + '@url': string; + '@length': number; + '@type': string; + enclosure: Enclosure; +}; + +export type RSSItemType = { + title: string; + description: string; + link: string; + category: BlogPostTypes; + guid: any; + pubDate: string; + enclosure: Enclosure; +}; +export type RSS = { + '@version': string; + '@xmlns:atom': string; + channel: { + title: string; + link: string; + 'atom:link': { + '@rel': string; + '@href': string; + '@type': string; + }; + description: string; + language: string; + copyright: string; + webMaster: string; + pubDate: string; // UTC string format + generator: string; + item: RSSItemType[]; + }; +};