From 203885bdc3814f1619e1085bcb382f1656c72f6e Mon Sep 17 00:00:00 2001 From: Lucas Arcoverde Date: Fri, 1 Nov 2024 16:19:51 -0300 Subject: [PATCH] docs(vercel): fix env variable value --- .github/workflows/preview.yml | 2 +- packages/docs/scripts/build-contributors.mjs | 169 ++++++++++--------- 2 files changed, 89 insertions(+), 82 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 5afc9ab4c..f690de2c0 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -2,7 +2,7 @@ name: Vercel Preview Deployment env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} - VTEX_GITHUB_BOT_TOKEN: ${{ secrets.VTEX_GITHUB_BOT_TOKEN }} + VTEX_GITHUB_BOT_TOKEN: ${{ secrets.DOC_GH_TOKEN }} on: push: branches-ignore: diff --git a/packages/docs/scripts/build-contributors.mjs b/packages/docs/scripts/build-contributors.mjs index 9421a117a..fe6806935 100644 --- a/packages/docs/scripts/build-contributors.mjs +++ b/packages/docs/scripts/build-contributors.mjs @@ -14,9 +14,7 @@ const REPO_NAME = "shoreline"; const token = process.env.VTEX_GITHUB_BOT_TOKEN ?? ""; const startDate = new Date("2024-01-01T00:00:00Z").toISOString(); -if (!token) { - console.log("Github token invalid!"); -} +console.log(`${!token ? "Invalid" : "Valid"} Github token!`); const graphqlWithAuth = graphql.defaults({ headers: { @@ -329,39 +327,42 @@ async function main() { */ const code = ` export interface Contributor { - username: string - image: string - stats: { - issues: number - pulls: number - reviews: number - comments: number - merged: number - assigns: number - rate: number - } + username: string; + image: string; + stats: { + issues: number; + pulls: number; + reviews: number; + comments: number; + merged: number; + assigns: number; + rate: number; + }; } -export const contributors: Contributor[] = ${JSON.stringify(stats)} +export const contributors: Contributor[] = $ +{ + JSON.stringify(stats); +} export function getContributor(username: string) { return contributors.find((contributor) => contributor.username === username) } const maintainers = [ - 'matheusps', - 'davicostalf', - 'lucasaarcoverde', - 'beatrizmilhomem', -] + "matheusps", + "davicostalf", + "lucasaarcoverde", + "beatrizmilhomem", +]; export function getContributors() { - return contributors.filter( - (contributor) => - !maintainers.includes(contributor.username) && contributor.stats.rate > 0 - ) + return contributors.filter( + (contributor) => + !maintainers.includes(contributor.username) && contributor.stats.rate > 0, + ); } - `; +`; const formattedCode = await format(code, { parser: "typescript", @@ -369,18 +370,24 @@ export function getContributors() { singleQuote: true, }); - fse.outputFile(`${statsOutputDirectory}/stats.ts`, formattedCode, (err) => { - if (err) { - console.log(err); - } else { - console.log("✅ Contributor stats generated"); - } - }); + fse.outputFile(`; +$; +{ + statsOutputDirectory; +} +/ (),,.=>C`aaddeeefmoorrrsssttttt{; + if (err) { + console.log(err); + } else { + console.log("✅ Contributor stats generated"); + } +} +) - /** - * Generate issues stats file - */ - const issuesCode = ` +/** + * Generate issues stats file + */ +const issuesCode = ` interface Author { login: string avatarUrl: string @@ -400,29 +407,29 @@ export interface Issue { export const issuesOnFire: Issue[] = ${JSON.stringify(issuesOnFire)} `; - const formattedIssuesCode = await format(issuesCode, { - parser: "typescript", - semi: false, - singleQuote: true, - }); +const formattedIssuesCode = await format(issuesCode, { + parser: "typescript", + semi: false, + singleQuote: true, +}); - fse.outputFile( - `${statsOutputDirectory}/issues.ts`, - formattedIssuesCode, - (err) => { - if (err) { - console.log(err); - } else { - console.log("✅ Issues on fire generated"); - } - }, - ); +fse.outputFile( + `${statsOutputDirectory}/issues.ts`, + formattedIssuesCode, + (err) => { + if (err) { + console.log(err); + } else { + console.log("✅ Issues on fire generated"); + } + }, +); - /** - * Generate contributor page files - */ - const contributorsPromises = contributors.map((contributor) => { - const mdxCode = ` +/** + * Generate contributor page files + */ +const contributorsPromises = contributors.map((contributor) => { + const mdxCode = ` --- toc: false --- @@ -436,31 +443,31 @@ import { getContributor } from '../../../__contributions__/stats'; `; - return format(mdxCode, { - parser: "mdx", - semi: false, - singleQuote: true, - }); + return format(mdxCode, { + parser: "mdx", + semi: false, + singleQuote: true, }); +}); - const contributorsMDX = await Promise.all(contributorsPromises); - - for (const i in contributors) { - const contributor = contributors[i]; - const contributorMDX = contributorsMDX[i]; - - fse.outputFile( - `${contributorsOutputDirectory}/${contributor.username}.mdx`, - contributorMDX, - (err) => { - if (err) { - console.log(err); - } else { - console.log(`✅ ${contributor.username} page generated`); - } - }, - ); - } +const contributorsMDX = await Promise.all(contributorsPromises); + +for (const i in contributors) { + const contributor = contributors[i]; + const contributorMDX = contributorsMDX[i]; + + fse.outputFile( + `${contributorsOutputDirectory}/${contributor.username}.mdx`, + contributorMDX, + (err) => { + if (err) { + console.log(err); + } else { + console.log(`✅ ${contributor.username} page generated`); + } + }, + ); +} } -main(); +main()