Skip to content

Commit ccac5ce

Browse files
committed
chore: ran prettier
also testing webhook
1 parent 78b0f6e commit ccac5ce

File tree

5 files changed

+63
-49
lines changed

5 files changed

+63
-49
lines changed

.github/scripts/webhook.js

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,44 @@
1-
const https = require('https');
1+
const https = require("https");
22

33
async function sendDiscordNotification(webhookUrl, commits, fileCount) {
44
if (!webhookUrl) {
5-
throw new Error('DISCORD_WEBHOOK_URL secret is missing');
5+
throw new Error("DISCORD_WEBHOOK_URL secret is missing");
66
}
77

88
if (!commits || commits.length === 0) {
9-
throw new Error('No commits found in this push event');
9+
throw new Error("No commits found in this push event");
1010
}
1111

12-
const fields = commits.map((commit) => {
13-
const commitFields = [
14-
{ name: `Commit ${commit.sha}`, value: commit.message, inline: false }
15-
];
12+
const fields = commits
13+
.map((commit) => {
14+
const commitFields = [
15+
{ name: `Commit ${commit.sha}`, value: commit.message, inline: false },
16+
];
1617

17-
const body = commit.full_message.split('\n').slice(1).join('\n').trim();
18-
if (body !== '') {
19-
commitFields.push({ name: 'Details', value: body, inline: false });
20-
}
18+
const body = commit.full_message.split("\n").slice(1).join("\n").trim();
19+
if (body !== "") {
20+
commitFields.push({ name: "Details", value: body, inline: false });
21+
}
22+
23+
commitFields.push({ name: "By", value: commit.author, inline: true });
2124

22-
commitFields.push({ name: 'By', value: commit.author, inline: true });
23-
24-
return commitFields;
25-
}).flat();
25+
return commitFields;
26+
})
27+
.flat();
2628

27-
fields.push({ name: 'Files Updated', value: `${fileCount} file(s)`, inline: true });
29+
fields.push({
30+
name: "Files Updated",
31+
value: `${fileCount} file(s)`,
32+
inline: true,
33+
});
2834

2935
const embed = {
30-
title: 'TDS Statistics Editor Update',
36+
title: "TDS Statistics Editor Update",
3137
description: `Push contains ${commits.length} commit(s)`,
3238
color: 5763719,
3339
fields,
34-
footer: { text: 'Thank you for using the Statistics Editor!' },
35-
timestamp: new Date().toISOString()
40+
footer: { text: "Thank you for using the Statistics Editor!" },
41+
timestamp: new Date().toISOString(),
3642
};
3743

3844
const payload = { embeds: [embed] };
@@ -43,30 +49,36 @@ async function sendDiscordNotification(webhookUrl, commits, fileCount) {
4349
const options = {
4450
hostname: url.hostname,
4551
path: url.pathname + url.search,
46-
method: 'POST',
52+
method: "POST",
4753
headers: {
48-
'Content-Type': 'application/json',
49-
'Content-Length': Buffer.byteLength(data),
50-
'User-Agent': 'github-actions/discord-notify'
51-
}
54+
"Content-Type": "application/json",
55+
"Content-Length": Buffer.byteLength(data),
56+
"User-Agent": "github-actions/discord-notify",
57+
},
5258
};
5359

5460
const req = https.request(options, (res) => {
55-
let body = '';
56-
res.on('data', (d) => body += d);
57-
res.on('end', () => {
61+
let body = "";
62+
res.on("data", (d) => (body += d));
63+
res.on("end", () => {
5864
if (res.statusCode < 200 || res.statusCode >= 300) {
59-
reject(new Error(`Failed to post to Discord: HTTP ${res.statusCode} ${body}`));
65+
reject(
66+
new Error(
67+
`Failed to post to Discord: HTTP ${res.statusCode} ${body}`,
68+
),
69+
);
6070
} else {
61-
resolve('Discord webhook posted successfully');
71+
resolve("Discord webhook posted successfully");
6272
}
6373
});
6474
});
6575

66-
req.on('error', (err) => reject(new Error(`Failed to post to Discord: ${err.message}`)));
76+
req.on("error", (err) =>
77+
reject(new Error(`Failed to post to Discord: ${err.message}`)),
78+
);
6779
req.write(data);
6880
req.end();
6981
});
7082
}
7183

72-
module.exports = { sendDiscordNotification };
84+
module.exports = { sendDiscordNotification };

.github/workflows/webhook.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
id: commit
2020
run: |
2121
COMMITS_JSON=$(git log --oneline ${{ github.event.before }}..${{ github.event.after }} --format='%h%x00%an%x00%s%x00%B%x00' | jq -R -s 'split("\u0000") | map(select(. != "")) as $lines | [range(0; $lines | length; 4) as $i | $lines[$i:$i+4]] | map({sha: .[0], author: .[1], message: .[2], full_message: .[3]}) | .')
22-
22+
2323
echo "commits_json=$COMMITS_JSON" >> $GITHUB_OUTPUT
2424
2525
- name: Get changed files count
@@ -33,18 +33,18 @@ jobs:
3333
with:
3434
script: |
3535
const { sendDiscordNotification } = require('./.github/scripts/webhook.js');
36-
36+
3737
const commits = JSON.parse(process.env.COMMITS_JSON || '[]');
3838
const fileCount = parseInt(process.env.FILE_COUNT || '0');
39-
39+
4040
await sendDiscordNotification(
4141
process.env.DISCORD_WEBHOOK_URL,
4242
commits,
4343
fileCount
4444
);
45-
45+
4646
console.log('Discord webhook posted successfully');
4747
env:
4848
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
4949
COMMITS_JSON: ${{ steps.commit.outputs.commits_json }}
50-
FILE_COUNT: ${{ steps.changed-files.outputs.all_changed_files_count }}
50+
FILE_COUNT: ${{ steps.changed-files.outputs.all_changed_files_count }}

TowerComponents/CalculatedManager.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -486,13 +486,7 @@ class CalculatedManager {
486486
// },
487487
Missiles: {
488488
For: ["Pursuit"],
489-
Requires: [
490-
"Damage",
491-
"Cooldown",
492-
"Ammo",
493-
"ReloadTime",
494-
"RevTime",
495-
],
489+
Requires: ["Damage", "Cooldown", "Ammo", "ReloadTime", "RevTime"],
496490
Value: (level) =>
497491
(level.Damage * level.Ammo) /
498492
(level.ReloadTime + level.RevTime + level.Cooldown * level.Ammo),
@@ -829,9 +823,7 @@ class CalculatedManager {
829823
},
830824
},
831825
Pursuit: {
832-
For: [
833-
"Pursuit"
834-
],
826+
For: ["Pursuit"],
835827
Requires: [
836828
"ExplosionDamage",
837829
"MissileCooldown",
@@ -1214,7 +1206,12 @@ class CalculatedManager {
12141206
const { extraCooldown, firerateBuff, RateOfFireBug } =
12151207
window.state.boosts.tower;
12161208

1217-
return Math.round((cooldown / (firerateBuff + 1) + extraCooldown + RateOfFireBug) * 1000) / 1000;
1209+
return (
1210+
Math.round(
1211+
(cooldown / (firerateBuff + 1) + extraCooldown + RateOfFireBug) *
1212+
1000,
1213+
) / 1000
1214+
);
12181215
},
12191216
},
12201217
},

TowerComponents/UnitCalculations.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,12 @@ class UnitCalculations {
269269
const { extraCooldown, firerateBuff, RateOfFireBug } =
270270
window.state.boosts.unit;
271271

272-
return Math.round((cooldown / (firerateBuff + 1) + extraCooldown + RateOfFireBug) * 1000) / 1000;
272+
return (
273+
Math.round(
274+
(cooldown / (firerateBuff + 1) + extraCooldown + RateOfFireBug) *
275+
1000,
276+
) / 1000
277+
);
273278
},
274279
},
275280
},

components/TableInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export default class TableInput {
316316
formatter.format(value) +
317317
(showStuds ? " " + (value === 1 ? "stud" : "studs") : "")
318318
);
319-
319+
320320
case "Speed":
321321
case "RocketSpeed":
322322
return (

0 commit comments

Comments
 (0)