diff --git a/.github/actions/label-products/index.ts b/.github/actions/label-products/index.ts index ad48385071a9df..bc42cc30abdd45 100644 --- a/.github/actions/label-products/index.ts +++ b/.github/actions/label-products/index.ts @@ -1,115 +1,113 @@ // NOTE: This is the source file! // ~> Run `npm run build` to produce `index.js` -import * as github from '@actions/github'; -import * as core from '@actions/core'; +import * as github from "@actions/github"; +import * as core from "@actions/core"; function getTopLevelFolder(path: string): string { - const parts = path.split('/'); - return parts[2]; + const parts = path.split("/"); + return parts[2]; } - function getSubFolder(path: string): string { - const parts = path.split('/'); - return parts[3]; + const parts = path.split("/"); + return parts[3]; } function getChangedSubFolders(files: any[]): string[] { - const changedFolders = new Set(); + const changedFolders = new Set(); - for (const file of files) { - const path = file.filename; - const topLevelFolder = getTopLevelFolder(path); + for (const file of files) { + const path = file.filename; + const topLevelFolder = getTopLevelFolder(path); - // Check if the file is within the top-level /content folder - if (topLevelFolder === 'docs') { - const subFolder = getSubFolder(path); - changedFolders.add(subFolder); - } - } + // Check if the file is within the top-level /content folder + if (topLevelFolder === "docs") { + const subFolder = getSubFolder(path); + changedFolders.add(subFolder); + } + } - return Array.from(changedFolders); + return Array.from(changedFolders); } async function run(): Promise { - try { - const ctx = github.context; - const token = core.getInput('GITHUB_TOKEN', { required: true }); - const octokit = github.getOctokit(token); - const pr = ctx.payload.pull_request; - const prNumber = pr.number; - const files = await octokit.paginate(octokit.rest.pulls.listFiles, { - ...ctx.repo, - pull_number: pr.number, - per_page: 100, - }); - - // Get the changed sub-folders within the top-level /content folder - const changedFolders = getChangedSubFolders(files); - - // ... - - // Label the PR based on the changed sub-folders - await labelPRSubFolders(octokit, ctx.repo, prNumber, changedFolders); - - // ... - } catch (error) { - console.error('An error occurred:', error); - process.exit(1); - } + try { + const ctx = github.context; + const token = core.getInput("GITHUB_TOKEN", { required: true }); + const octokit = github.getOctokit(token); + const pr = ctx.payload.pull_request; + const prNumber = pr.number; + const files = await octokit.paginate(octokit.rest.pulls.listFiles, { + ...ctx.repo, + pull_number: pr.number, + per_page: 100, + }); + + // Get the changed sub-folders within the top-level /content folder + const changedFolders = getChangedSubFolders(files); + + // ... + + // Label the PR based on the changed sub-folders + await labelPRSubFolders(octokit, ctx.repo, prNumber, changedFolders); + + // ... + } catch (error) { + console.error("An error occurred:", error); + process.exit(1); + } } async function labelPRSubFolders( - octokit: any, - repo: any, - prNumber: number, - changedFolders: string[] + octokit: any, + repo: any, + prNumber: number, + changedFolders: string[], ): Promise { - const labelPrefix = 'product:'; - const labelsToRemove: string[] = []; - const labelsToAdd: string[] = []; - - for (const label of github.context.payload.pull_request.labels) { - if (label.name.startsWith(labelPrefix)) { - labelsToRemove.push(label.name); - } - } - - for (const folder of changedFolders) { - const label = labelPrefix + folder; - labelsToAdd.push(label); - } - - const currentLabels = new Set( - github.context.payload.pull_request.labels.map((label: any) => label.name) - ); - - for (const labelToRemove of labelsToRemove) { - if (!labelsToAdd.includes(labelToRemove)) { - await octokit.rest.issues.removeLabel({ - ...repo, - issue_number: prNumber, - name: labelToRemove, - }); - } - } - - let newLabels: string[] = []; - for (const labelToAdd of labelsToAdd) { - if (!currentLabels.has(labelToAdd)) { - newLabels.push(labelToAdd); - } - } - - if (newLabels.length > 0) { - await octokit.rest.issues.addLabels({ - ...repo, - issue_number: prNumber, - labels: newLabels, - }); - } + const labelPrefix = "product:"; + const labelsToRemove: string[] = []; + const labelsToAdd: string[] = []; + + for (const label of github.context.payload.pull_request.labels) { + if (label.name.startsWith(labelPrefix)) { + labelsToRemove.push(label.name); + } + } + + for (const folder of changedFolders) { + const label = labelPrefix + folder; + labelsToAdd.push(label); + } + + const currentLabels = new Set( + github.context.payload.pull_request.labels.map((label: any) => label.name), + ); + + for (const labelToRemove of labelsToRemove) { + if (!labelsToAdd.includes(labelToRemove)) { + await octokit.rest.issues.removeLabel({ + ...repo, + issue_number: prNumber, + name: labelToRemove, + }); + } + } + + let newLabels: string[] = []; + for (const labelToAdd of labelsToAdd) { + if (!currentLabels.has(labelToAdd)) { + newLabels.push(labelToAdd); + } + } + + if (newLabels.length > 0) { + await octokit.rest.issues.addLabels({ + ...repo, + issue_number: prNumber, + labels: newLabels, + }); + } } run(); - diff --git a/.github/actions/label-size/index.ts b/.github/actions/label-size/index.ts index 2f27ea7fb338f6..0b265ea53e808a 100644 --- a/.github/actions/label-size/index.ts +++ b/.github/actions/label-size/index.ts @@ -1,67 +1,68 @@ -import * as core from '@actions/core'; -import * as github from '@actions/github'; +import * as core from "@actions/core"; +import * as github from "@actions/github"; async function run(): Promise { - try { - const ctx = github.context; - const token = core.getInput('GITHUB_TOKEN', { required: true }); - const octokit = github.getOctokit(token); - const pr = ctx.payload.pull_request; - const files = await octokit.paginate(octokit.rest.pulls.listFiles, { - ...ctx.repo, - pull_number: pr.number, - per_page: 100 - }); + try { + const ctx = github.context; + const token = core.getInput("GITHUB_TOKEN", { required: true }); + const octokit = github.getOctokit(token); + const pr = ctx.payload.pull_request; + const files = await octokit.paginate(octokit.rest.pulls.listFiles, { + ...ctx.repo, + pull_number: pr.number, + per_page: 100, + }); - const changes = files.reduce((total, file) => total + file.changes, 0); + const changes = files.reduce((total, file) => total + file.changes, 0); - let label: string | undefined; + let label: string | undefined; - switch (true) { - case changes <= 10: - label = 'size/xs'; - break; - case changes <= 100: - label = 'size/s'; - break; - case changes <= 500: - label = 'size/m'; - break; - case changes <= 1000: - label = 'size/l'; - break; - default: - label = 'size/xl'; - break; - } + switch (true) { + case changes <= 10: + label = "size/xs"; + break; + case changes <= 100: + label = "size/s"; + break; + case changes <= 500: + label = "size/m"; + break; + case changes <= 1000: + label = "size/l"; + break; + default: + label = "size/xl"; + break; + } - const currentLabels = pr.labels.map((label) => label.name); - const sizeLabels = ['size/xs', 'size/s', 'size/m', 'size/l', 'size/xl']; + const currentLabels = pr.labels.map((label) => label.name); + const sizeLabels = ["size/xs", "size/s", "size/m", "size/l", "size/xl"]; - // Remove previous size-related labels that are different from the current label - const labelsToRemove = currentLabels.filter( - (currentLabel) => sizeLabels.includes(currentLabel) && currentLabel !== label - ); + // Remove previous size-related labels that are different from the current label + const labelsToRemove = currentLabels.filter( + (currentLabel) => + sizeLabels.includes(currentLabel) && currentLabel !== label, + ); - for (const labelToRemove of labelsToRemove) { - await octokit.rest.issues.removeLabel({ - ...ctx.repo, - issue_number: pr.number, - name: labelToRemove - }); - } + for (const labelToRemove of labelsToRemove) { + await octokit.rest.issues.removeLabel({ + ...ctx.repo, + issue_number: pr.number, + name: labelToRemove, + }); + } - // Add the current label - if (!currentLabels.includes(label)) { - await octokit.rest.issues.addLabels({ - ...ctx.repo, - issue_number: pr.number, - labels: [label] - }); - } - } catch (error) { - core.setFailed(error.message); - } + // Add the current label + if (!currentLabels.includes(label)) { + await octokit.rest.issues.addLabels({ + ...ctx.repo, + issue_number: pr.number, + labels: [label], + }); + } + } catch (error) { + core.setFailed(error.message); + } } run(); diff --git a/src/content/docs/src/env.d.ts b/src/content/docs/src/env.d.ts index 9bc5cb41c24efc..e16c13c6952a6f 100644 --- a/src/content/docs/src/env.d.ts +++ b/src/content/docs/src/env.d.ts @@ -1 +1 @@ -/// \ No newline at end of file +/// diff --git a/src/env.d.ts b/src/env.d.ts index 9bc5cb41c24efc..e16c13c6952a6f 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -1 +1 @@ -/// \ No newline at end of file +/// diff --git a/src/pages/pages/platform/build-configuration.json.ts b/src/pages/pages/platform/build-configuration.json.ts index 209ed9351e625a..0928b6786ee5d7 100644 --- a/src/pages/pages/platform/build-configuration.json.ts +++ b/src/pages/pages/platform/build-configuration.json.ts @@ -1,9 +1,11 @@ import { getEntry } from "astro:content"; export async function GET() { - const entries = await getEntry("pages-framework-presets", "index"); + const entries = await getEntry("pages-framework-presets", "index"); - const sorted = Object.fromEntries(Object.entries(entries.data.build_configs).sort()) + const sorted = Object.fromEntries( + Object.entries(entries.data.build_configs).sort(), + ); - return Response.json(sorted); -} \ No newline at end of file + return Response.json(sorted); +} diff --git a/src/util/container.ts b/src/util/container.ts index 746c77546d261c..13262407b41e3b 100644 --- a/src/util/container.ts +++ b/src/util/container.ts @@ -19,5 +19,5 @@ export async function entryToString(entry: CollectionEntry<"docs">) { params: { slug: entry.slug }, }); - return html; + return html; } diff --git a/src/util/description.ts b/src/util/description.ts index 658790d7fd2bc7..da762f7efa42fb 100644 --- a/src/util/description.ts +++ b/src/util/description.ts @@ -1,6 +1,6 @@ import type { CollectionEntry } from "astro:content"; import { parse } from "node-html-parser"; -import { entryToString } from "./container" +import { entryToString } from "./container"; /* 1. If there is a `description` property in the frontmatter, return that. 2. If there is a `

...

` element in the HTML, return that. diff --git a/src/util/sidebar.ts b/src/util/sidebar.ts index f747c0b90377bf..ab2cb411c0610c 100644 --- a/src/util/sidebar.ts +++ b/src/util/sidebar.ts @@ -1,7 +1,8 @@ export function sortBySidebarOrder(a: any, b: any): number { - const collator = new Intl.Collator("en"); + const collator = new Intl.Collator("en"); - if (a.data.sidebar.order !== b.data.sidebar.order) return a.data.sidebar.order - b.data.sidebar.order; + if (a.data.sidebar.order !== b.data.sidebar.order) + return a.data.sidebar.order - b.data.sidebar.order; - return collator.compare(a.data.title, b.data.title); -} \ No newline at end of file + return collator.compare(a.data.title, b.data.title); +}