diff --git a/eng/common/scripts/labels/automation.ts b/eng/common/scripts/labels/automation.ts index b6437e0449..7b4e3b3da9 100644 --- a/eng/common/scripts/labels/automation.ts +++ b/eng/common/scripts/labels/automation.ts @@ -1,6 +1,6 @@ import { resolve } from "path"; import { stringify } from "yaml"; -import { CheckOptions, repoRoot, syncFile } from "../common.js"; +import { CheckOptions, syncFile } from "../common.js"; import { PolicyServiceConfig, and, @@ -95,37 +95,36 @@ function createIssueTriageConfig(config: RepoConfig): PolicyServiceConfig { }, }, }; -}; +} function createPrTriageConfig(config: RepoConfig): PolicyServiceConfig { - -return { - id: "prs.triage", - name: "Assign area labels to PRs", - description: "Assign area labels to PR depending on path modified.", - resource: "repository", - disabled: false, - configuration: { - resourceManagementConfiguration: { - eventResponderTasks: [ - eventResponderTask({ - if: [payloadType("Pull_Request")], - then: Object.entries(config.areaPaths).flatMap(([label, files]) => { - return files.map((file) => { - return { - if: [filesMatchPattern(`${file}.*`)], - then: [ - { - addLabel: { - label, + return { + id: "prs.triage", + name: "Assign area labels to PRs", + description: "Assign area labels to PR depending on path modified.", + resource: "repository", + disabled: false, + configuration: { + resourceManagementConfiguration: { + eventResponderTasks: [ + eventResponderTask({ + if: [payloadType("Pull_Request")], + then: Object.entries(config.areaPaths).flatMap(([label, files]) => { + return files.map((file) => { + return { + if: [filesMatchPattern(`${file}.*`)], + then: [ + { + addLabel: { + label, + }, }, - }, - ], - }; - }); + ], + }; + }); + }), }), - }), - ], + ], + }, }, - }, -}; -}; + }; +} diff --git a/eng/common/scripts/labels/sync-labels.ts b/eng/common/scripts/labels/sync-labels.ts index cee585f3f6..192e00efe2 100644 --- a/eng/common/scripts/labels/sync-labels.ts +++ b/eng/common/scripts/labels/sync-labels.ts @@ -1,13 +1,13 @@ +import { resolve } from "path"; import { parseArgs } from "util"; import { syncLabelAutomation } from "./automation.js"; import { syncLabelsDefinitions } from "./definitions.js"; -import { resolve } from "path"; import { RepoConfig } from "./types.js"; const options = parseArgs({ args: process.argv.slice(2), options: { - "config": { + config: { type: "string", description: "The directory where the labels configuration is stored.", }, @@ -23,7 +23,7 @@ const options = parseArgs({ }, }); -if(!options.values["config"]) { +if (!options.values["config"]) { throw new Error("--config is required"); } @@ -39,8 +39,7 @@ await syncLabelAutomation(config, { check: options.values["check"], }); - async function loadConfig(configFile: string): Promise { - const module = await import(resolve(process.cwd(), configFile)); + const module = await import(resolve(process.cwd(), configFile)); return module.default; } diff --git a/eng/common/scripts/labels/types.ts b/eng/common/scripts/labels/types.ts index 33e39ea8ef..a461d553d1 100644 --- a/eng/common/scripts/labels/types.ts +++ b/eng/common/scripts/labels/types.ts @@ -2,14 +2,14 @@ export interface RepoConfig { repo: { owner: string; repo: string; - }, + }; labels: LabelsConfig; areaPaths: Record; } export interface LabelsConfig { area: LabelCategory; - [key: string]: LabelCategory + [key: string]: LabelCategory; } export interface LabelCategory {