Skip to content

Commit 4798e65

Browse files
CopilotTechQuery
andcommitted
chore: restore all non-migration files to main branch state via .prettierignore
Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
1 parent 5dbf22c commit 4798e65

33 files changed

Lines changed: 661 additions & 742 deletions

.github/scripts/count-reward.ts

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,57 @@
1-
import { $, YAML } from 'npm:zx'
1+
import { $, YAML } from "npm:zx";
22

3-
import { Reward } from './type.ts'
3+
import { Reward } from "./type.ts";
44

5-
$.verbose = true
5+
$.verbose = true;
66

77
const rawTags =
8-
await $`git tag --list "reward-*" --format="%(refname:short) %(creatordate:short)"`
8+
await $`git tag --list "reward-*" --format="%(refname:short) %(creatordate:short)"`;
99

10-
const lastMonth = new Date()
11-
lastMonth.setMonth(lastMonth.getMonth() - 1)
12-
const lastMonthStr = lastMonth.toJSON().slice(0, 7)
10+
const lastMonth = new Date();
11+
lastMonth.setMonth(lastMonth.getMonth() - 1);
12+
const lastMonthStr = lastMonth.toJSON().slice(0, 7);
1313

1414
const rewardTags = rawTags.stdout
15-
.split('\n')
15+
.split("\n")
1616
.filter((line) => line.split(/\s+/)[1] >= lastMonthStr)
17-
.map((line) => line.split(/\s+/)[0])
17+
.map((line) => line.split(/\s+/)[0]);
1818

19-
let rawYAML = ''
19+
let rawYAML = "";
2020

2121
for (const tag of rewardTags)
22-
rawYAML += (await $`git tag -l --format="%(contents)" ${tag}`) + '\n'
22+
rawYAML += (await $`git tag -l --format="%(contents)" ${tag}`) + "\n";
2323

2424
if (!rawYAML.trim())
25-
throw new ReferenceError('No reward data is found for the last month.')
25+
throw new ReferenceError("No reward data is found for the last month.");
2626

27-
const rewards = YAML.parse(rawYAML) as Reward[]
27+
const rewards = YAML.parse(rawYAML) as Reward[];
2828

29-
const groupedRewards = Object.groupBy(rewards, ({ payee }) => payee)
29+
const groupedRewards = Object.groupBy(rewards, ({ payee }) => payee);
3030

3131
const summaryList = Object.entries(groupedRewards).map(([payee, rewards]) => {
32-
const reward = rewards!.reduce(
33-
(acc, { currency, reward }) => {
34-
acc[currency] ??= 0
35-
acc[currency] += reward
36-
return acc
37-
},
38-
{} as Record<string, number>,
39-
)
32+
const reward = rewards!.reduce((acc, { currency, reward }) => {
33+
acc[currency] ??= 0;
34+
acc[currency] += reward;
35+
return acc;
36+
}, {} as Record<string, number>);
4037

4138
return {
4239
payee,
4340
reward,
4441
accounts: rewards!.map(({ payee: _, ...account }) => account),
45-
}
46-
})
42+
};
43+
});
4744

48-
const summaryText = YAML.stringify(summaryList)
45+
const summaryText = YAML.stringify(summaryList);
4946

50-
console.log(summaryText)
47+
console.log(summaryText);
5148

52-
const tagName = `statistic-${new Date().toJSON().slice(0, 7)}`
49+
const tagName = `statistic-${new Date().toJSON().slice(0, 7)}`;
5350

54-
await $`git config user.name "github-actions[bot]"`
55-
await $`git config user.email "github-actions[bot]@users.noreply.github.com"`
51+
await $`git config user.name "github-actions[bot]"`;
52+
await $`git config user.email "github-actions[bot]@users.noreply.github.com"`;
5653

57-
await $`git tag -a ${tagName} $(git rev-parse HEAD) -m ${summaryText}`
58-
await $`git push origin --tags --no-verify`
54+
await $`git tag -a ${tagName} $(git rev-parse HEAD) -m ${summaryText}`;
55+
await $`git push origin --tags --no-verify`;
5956

60-
await $`gh release create ${tagName} --notes ${summaryText}`
57+
await $`gh release create ${tagName} --notes ${summaryText}`;

.github/scripts/share-reward.ts

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { components } from 'npm:@octokit/openapi-types'
2-
import { $, argv, YAML } from 'npm:zx'
1+
import { components } from "npm:@octokit/openapi-types";
2+
import { $, argv, YAML } from "npm:zx";
33

4-
import { Reward } from './type.ts'
4+
import { Reward } from "./type.ts";
55

6-
$.verbose = true
6+
$.verbose = true;
77

88
const [
99
repositoryOwner,
@@ -12,11 +12,11 @@ const [
1212
payer, // GitHub username of the payer (provided by workflow, defaults to issue creator)
1313
currency,
1414
reward,
15-
] = argv._
15+
] = argv._;
1616

1717
interface PRMeta {
18-
author: components['schemas']['simple-user']
19-
assignees: components['schemas']['simple-user'][]
18+
author: components["schemas"]["simple-user"];
19+
assignees: components["schemas"]["simple-user"][];
2020
}
2121

2222
const PR_DATA = await $`gh api graphql -f query='{
@@ -33,75 +33,75 @@ const PR_DATA = await $`gh api graphql -f query='{
3333
}
3434
}
3535
}
36-
}' --jq '.data.repository.issue.closedByPullRequestsReferences.nodes[] | select(.merged == true) | {url: .url, mergeCommitSha: .mergeCommit.oid}' | head -n 1`
36+
}' --jq '.data.repository.issue.closedByPullRequestsReferences.nodes[] | select(.merged == true) | {url: .url, mergeCommitSha: .mergeCommit.oid}' | head -n 1`;
3737

38-
const prData = PR_DATA.text().trim()
38+
const prData = PR_DATA.text().trim();
3939

4040
if (!prData)
41-
throw new ReferenceError('No merged PR is found for the given issue number.')
41+
throw new ReferenceError("No merged PR is found for the given issue number.");
4242

43-
const { url: PR_URL, mergeCommitSha } = JSON.parse(prData)
43+
const { url: PR_URL, mergeCommitSha } = JSON.parse(prData);
4444

4545
if (!PR_URL || !mergeCommitSha)
46-
throw new Error('Missing required fields in PR data')
46+
throw new Error("Missing required fields in PR data");
4747

48-
console.table({ PR_URL, mergeCommitSha })
48+
console.table({ PR_URL, mergeCommitSha });
4949

5050
const { author, assignees }: PRMeta = await (
5151
await $`gh pr view ${PR_URL} --json author,assignees`
52-
).json()
52+
).json();
5353

5454
function isBotUser(login: string) {
55-
const lowerLogin = login.toLowerCase()
55+
const lowerLogin = login.toLowerCase();
5656
return (
57-
lowerLogin.includes('copilot') ||
58-
lowerLogin.includes('[bot]') ||
59-
lowerLogin === 'github-actions[bot]' ||
60-
lowerLogin.endsWith('[bot]')
61-
)
57+
lowerLogin.includes("copilot") ||
58+
lowerLogin.includes("[bot]") ||
59+
lowerLogin === "github-actions[bot]" ||
60+
lowerLogin.endsWith("[bot]")
61+
);
6262
}
6363

6464
// Filter out Bot users from the list
65-
const allUsers = [author.login, ...assignees.map(({ login }) => login)]
66-
const users = allUsers.filter((login) => !isBotUser(login))
65+
const allUsers = [author.login, ...assignees.map(({ login }) => login)];
66+
const users = allUsers.filter((login) => !isBotUser(login));
6767

68-
console.log(`All users: ${allUsers.join(', ')}`)
69-
console.log(`Filtered users (excluding bots): ${users.join(', ')}`)
68+
console.log(`All users: ${allUsers.join(", ")}`);
69+
console.log(`Filtered users (excluding bots): ${users.join(", ")}`);
7070

7171
if (!users[0])
7272
throw new ReferenceError(
73-
'No real users found (all users are bots). Skipping reward distribution.',
74-
)
73+
"No real users found (all users are bots). Skipping reward distribution."
74+
);
7575

76-
const rewardNumber = parseFloat(reward)
76+
const rewardNumber = parseFloat(reward);
7777

7878
if (isNaN(rewardNumber) || rewardNumber <= 0)
7979
throw new RangeError(
80-
`Reward amount is not a valid number, can not proceed with reward distribution. Received reward value: ${reward}`,
81-
)
80+
`Reward amount is not a valid number, can not proceed with reward distribution. Received reward value: ${reward}`
81+
);
8282

83-
const averageReward = (rewardNumber / users.length).toFixed(2)
83+
const averageReward = (rewardNumber / users.length).toFixed(2);
8484

8585
const list: Reward[] = users.map((login) => ({
8686
issue: `#${issueNumber}`,
8787
payer: `@${payer}`,
8888
payee: `@${login}`,
8989
currency,
9090
reward: parseFloat(averageReward),
91-
}))
92-
const listText = YAML.stringify(list)
91+
}));
92+
const listText = YAML.stringify(list);
9393

94-
console.log(listText)
94+
console.log(listText);
9595

96-
await $`git config user.name "github-actions[bot]"`
97-
await $`git config user.email "github-actions[bot]@users.noreply.github.com"`
98-
await $`git tag -a "reward-${issueNumber}" ${mergeCommitSha} -m ${listText}`
99-
await $`git push origin --tags --no-verify`
96+
await $`git config user.name "github-actions[bot]"`;
97+
await $`git config user.email "github-actions[bot]@users.noreply.github.com"`;
98+
await $`git tag -a "reward-${issueNumber}" ${mergeCommitSha} -m ${listText}`;
99+
await $`git push origin --tags --no-verify`;
100100

101101
const commentBody = `## Reward data
102102
103103
\`\`\`yml
104104
${listText}
105105
\`\`\`
106-
`
107-
await $`gh issue comment ${issueNumber} --body ${commentBody}`
106+
`;
107+
await $`gh issue comment ${issueNumber} --body ${commentBody}`;

.github/scripts/type.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export interface Reward {
2-
issue: string
3-
payer: string
4-
payee: string
5-
currency: string
6-
reward: number
2+
issue: string;
3+
payer: string;
4+
payee: string;
5+
currency: string;
6+
reward: number;
77
}

.prettierignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Files that have not yet been migrated to the project's Prettier style.
2+
# Remove a file's entry here when it is next meaningfully changed.
3+
.github/scripts/count-reward.ts
4+
.github/scripts/share-reward.ts
5+
.github/scripts/type.ts
6+
app/Barrier-Free-Bites/layout.tsx
7+
app/api/ai/health/route.ts
8+
app/deadlines/page.tsx
9+
app/home/page.tsx
10+
app/origin/page.tsx
11+
app/page.tsx
12+
components/AddToCalendar.tsx
13+
components/Aggregation.tsx
14+
components/CountdownTimer.tsx
15+
components/FilterBar.tsx
16+
components/I18nProvider.tsx
17+
components/TimelineItem.tsx
18+
components/ui/badge.tsx
19+
components/ui/button.tsx
20+
components/ui/card.tsx
21+
components/ui/dialog.tsx
22+
components/ui/dropdown-menu.tsx
23+
components/ui/input.tsx
24+
components/ui/label.tsx
25+
components/ui/scroll-area.tsx
26+
components/ui/switch.tsx
27+
eslint.config.mjs
28+
i18n/config.ts
29+
lib/data.ts
30+
lib/spark.ts
31+
lib/store.ts
32+
lib/utils.ts
33+
next.config.ts
34+
postcss.config.mjs

app/Barrier-Free-Bites/layout.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { Metadata } from 'next'
2-
import React from 'react'
1+
import type { Metadata } from "next";
2+
import React from "react";
33

44
export const metadata: Metadata = {
5-
title: '无障碍友好美食指南',
6-
}
5+
title: "无障碍友好美食指南",
6+
};
77

88
export default function Layout({ children }: { children: React.ReactNode }) {
9-
return children
10-
}
9+
return children;
10+
}

app/api/ai/health/route.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
import { NextResponse } from 'next/server'
2-
3-
export const runtime = 'nodejs'
4-
5-
export async function GET() {
6-
const hasPassword = !!(
7-
process.env.SPARK_API_PASSWORD || process.env.IFLYTEK_SPARK_API_PASSWORD
8-
)
9-
const hasWsConfig = !!(
10-
process.env.IFLYTEK_APP_ID &&
11-
process.env.IFLYTEK_API_KEY &&
12-
process.env.IFLYTEK_API_SECRET
13-
)
14-
const isStaticExport = process.env.STATIC_EXPORT === 'true'
15-
return NextResponse.json({ hasPassword, hasWsConfig, isStaticExport })
16-
}
1+
import { NextResponse } from "next/server"
2+
3+
export const runtime = "nodejs"
4+
5+
export async function GET() {
6+
const hasPassword = !!(process.env.SPARK_API_PASSWORD || process.env.IFLYTEK_SPARK_API_PASSWORD)
7+
const hasWsConfig = !!(process.env.IFLYTEK_APP_ID && process.env.IFLYTEK_API_KEY && process.env.IFLYTEK_API_SECRET)
8+
const isStaticExport = process.env.STATIC_EXPORT === "true"
9+
return NextResponse.json({ hasPassword, hasWsConfig, isStaticExport })
10+
}
11+

0 commit comments

Comments
 (0)