25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
feat(github): label user-reported issue priority
t8y2d3ac9805a429
diff --git a/.github/scripts/label-issue-database.mjs b/.github/scripts/label-issue-database.mjsindex cce8a13d2e..2062037ec4 100644--- a/.github/scripts/label-issue-database.mjs+++ b/.github/scripts/label-issue-database.mjs@@ -2,9 +2,17 @@import fs from "node:fs";const LABEL_PREFIX = "db/";+const USER_PRIORITY_PREFIX = "user-priority/";const API_VERSION = "2022-11-28";const dryRun = process.env.DRY_RUN === "1" || process.env.DRY_RUN === "true";+const USER_PRIORITY_LABELS = {+ P0: { color: "b60205", description: "User-reported priority: urgent" },+ P1: { color: "d93f0b", description: "User-reported priority: important" },+ P2: { color: "fbca04", description: "User-reported priority: normal" },+ P3: { color: "bfd4f2", description: "User-reported priority: low" },+};+const LABEL_PALETTE = ["0e8a16","1d76db",@@ -120,16 +128,11 @@ function stablePaletteColor(value) {return LABEL_PALETTE[hash % LABEL_PALETTE.length];}-function extractDatabaseField(body) {+function extractIssueFormSection(body, predicate) {const matches = [...String(body || "").matchAll(/^###\s+(.+?)\s*$/gm)];for (const [index, match] of matches.entries()) {const heading = match[1].trim();- const isDatabaseHeading =- heading.includes("数据库类型") ||- heading.toLowerCase().includes("database type") ||- /^database$/i.test(heading);-- if (!isDatabaseHeading) continue;+ if (!predicate(heading)) continue;const start = match.index + match[0].length;const end = matches[index + 1]?.index ?? body.length;@@ -139,6 +142,26 @@ function extractDatabaseField(body) {return "";}+function extractDatabaseField(body) {+ return extractIssueFormSection(body, (heading) => (+ heading.includes("数据库类型") ||+ heading.toLowerCase().includes("database type") ||+ /^database$/i.test(heading)+ ));+}++function extractPriorityField(body) {+ return extractIssueFormSection(body, (heading) => (+ heading.includes("优先级") ||+ heading.toLowerCase().includes("priority")+ ));+}++function matchPriorityLabel(value) {+ const match = String(value || "").normalize("NFKC").match(/\bP([0-3])\b/i);+ return match ? `P${match[1]}` : null;+}+function normalizeText(value) {return String(value || "").normalize("NFKC")@@ -313,10 +336,10 @@ async function githubRequest(method, path, body) {return payload;}-async function ensureLabel(name, description) {+async function ensureLabel(name, description, color) {try {const dbType = name.startsWith(LABEL_PREFIX) ? name.slice(LABEL_PREFIX.length) : name;- await githubRequest("POST", "/labels", { name, color: stablePaletteColor(dbType), description });+ await githubRequest("POST", "/labels", { name, color: color || stablePaletteColor(dbType), description });console.log(`Created label ${name}`);} catch (error) {// GitHub returns 422 when the label already exists; that is the common path@@ -378,12 +401,32 @@ const targetLabels = uniqueMatchedDrivers.map((driver) => `${LABEL_PREFIX}${drivconst targetLabelColors = Object.fromEntries(uniqueMatchedDrivers.map((driver) => [`${LABEL_PREFIX}${driver.dbType}`, stablePaletteColor(driver.dbType)]),);+const priorityField = extractPriorityField(issue.body || "");+const targetPriorityValue = matchPriorityLabel(priorityField);+const targetPriorityLabel = targetPriorityValue ? `${USER_PRIORITY_PREFIX}${targetPriorityValue}` : null;+if (targetPriorityValue) {+ targetLabelColors[targetPriorityLabel] = USER_PRIORITY_LABELS[targetPriorityValue].color;+}const existingLabels = labelNames(issue.labels);const existingDatabaseLabels = existingLabels.filter((name) => name.startsWith(LABEL_PREFIX));const staleDatabaseLabels = hasDatabaseField? existingDatabaseLabels.filter((name) => !targetLabels.includes(name)): [];-const labelsToAdd = targetLabels.filter((name) => !existingLabels.includes(name));+const existingPriorityLabels = existingLabels.filter((name) => name.startsWith(USER_PRIORITY_PREFIX));+const stalePriorityLabels = targetPriorityLabel+ ? existingPriorityLabels.filter((name) => name !== targetPriorityLabel)+ : [];+const labelsToAdd = [...targetLabels, targetPriorityLabel].filter(Boolean).filter((name) => !existingLabels.includes(name));+const labelSpecs = [+ ...uniqueMatchedDrivers.map((driver) => ({+ name: `${LABEL_PREFIX}${driver.dbType}`,+ description: `Database: ${driver.label}`,+ color: stablePaletteColor(driver.dbType),+ })),+ ...(targetPriorityValue+ ? [{ name: targetPriorityLabel, ...USER_PRIORITY_LABELS[targetPriorityValue] }]+ : []),+];console.log(JSON.stringify(@@ -392,9 +435,13 @@ console.log(databaseField: hasDatabaseField ? databaseField : null,titleMatched: titleMatchedDrivers.map(({ dbType, label, matchedAlias }) => ({ dbType, label, matchedAlias })),matched: uniqueMatchedDrivers.map(({ dbType, label, matchedAlias }) => ({ dbType, label, matchedAlias })),+ priorityField: priorityField || null,+ priorityLabel: targetPriorityLabel,+ priorityValue: targetPriorityValue,labelsToAdd,targetLabelColors,staleDatabaseLabels,+ stalePriorityLabels,},null,2,@@ -406,8 +453,8 @@ if (dryRun) {process.exit(0);}-for (const driver of uniqueMatchedDrivers) {- await ensureLabel(`${LABEL_PREFIX}${driver.dbType}`, `Database: ${driver.label}`);+for (const labelSpec of labelSpecs) {+ await ensureLabel(labelSpec.name, labelSpec.description, labelSpec.color);}if (labelsToAdd.length > 0) {@@ -420,3 +467,7 @@ if (labelsToAdd.length > 0) {for (const label of staleDatabaseLabels) {await removeLabel(issue.number, label);}++for (const label of stalePriorityLabels) {+ await removeLabel(issue.number, label);+}diff --git a/.github/workflows/issue-database-label.yml b/.github/workflows/issue-database-label.ymlindex e0daa5fbf1..ef4337b6fd 100644--- a/.github/workflows/issue-database-label.yml+++ b/.github/workflows/issue-database-label.yml@@ -1,4 +1,4 @@-name: Issue Database Label+name: Issue Triage Labelson:issues:@@ -24,7 +24,7 @@ jobs:with:node-version: 22.13.0- - name: Label issue by database+ - name: Label issue by database and priorityrun: node .github/scripts/label-issue-database.mjsenv:GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}