Skip to content

Commit d007cc3

Browse files
committed
refactor: migrated commonjs to esm
1 parent 5ffe177 commit d007cc3

File tree

5 files changed

+22
-38
lines changed

5 files changed

+22
-38
lines changed

.github/scripts/notify.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
// require("dotenv").config();
2-
const fetch = require("node-fetch");
3-
const FormData = require("form-data");
4-
const { execSync } = require("child_process");
1+
import 'dotenv/config';
2+
import { execSync } from "child_process";
53

64
const WIKI_BASE = process.env.WIKI_BASE || "https://tds.fandom.com";
75
const USER_AGENT = process.env.USER_AGENT || "DarkGabonnie/1.048596";
@@ -381,4 +379,4 @@ async function main() {
381379
}
382380
}
383381

384-
main();
382+
main();

.github/workflows/notify.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ jobs:
2323
with:
2424
node-version: "22"
2525

26-
- name: Install dependencies
27-
run: |
28-
npm install node-fetch@2 form-data
29-
3026
- name: Detect changes and notify users
3127
run: node .github/scripts/notify.js
3228
env:

.github/workflows/webhook.yml

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,39 +49,28 @@ jobs:
4949
description: `Push contains ${commits.length} commit(s)`,
5050
color: 5763719,
5151
fields,
52-
footer: { text: 'Thank you for using the Statisics Editor!' },
52+
footer: { text: 'Thank you for using the Statistics Editor!' },
5353
timestamp: new Date().toISOString()
5454
};
5555
5656
const payload = { embeds: [embed] };
57-
58-
const { request } = require('https');
59-
const u = new URL(webhookUrl);
6057
const data = JSON.stringify(payload);
6158
62-
const options = {
63-
hostname: u.hostname,
64-
path: u.pathname + u.search,
65-
method: 'POST',
66-
headers: {
67-
'Content-Type': 'application/json',
68-
'Content-Length': Buffer.byteLength(data),
69-
'User-Agent': 'github-actions/discord-notify'
70-
}
71-
};
72-
73-
const req = request(options, res => {
74-
let body = '';
75-
res.on('data', d => body += d);
76-
res.on('end', () => {
77-
if (res.statusCode < 200 || res.statusCode >= 300) {
78-
core.setFailed(`Failed to post to Discord: HTTP ${res.statusCode} ${body}`);
79-
} else {
80-
core.info('Discord webhook posted successfully');
81-
}
59+
try {
60+
const response = await fetch(webhookUrl, {
61+
method: 'POST',
62+
headers: {
63+
'Content-Type': 'application/json',
64+
'User-Agent': 'github-actions/discord-notify'
65+
},
66+
body: data
8267
});
83-
});
8468
85-
req.on('error', err => core.setFailed(`Failed to post to Discord: ${err.message}`));
86-
req.write(data);
87-
req.end();
69+
if (!response.ok) {
70+
core.setFailed(`Failed to post to Discord: HTTP ${response.status} ${response.statusText}`);
71+
} else {
72+
core.info('Discord webhook posted successfully');
73+
}
74+
} catch (error) {
75+
core.setFailed(`Failed to post to Discord: ${error.message}`);
76+
}

components/Viewer/ViewerUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Alert from "../Alert.js";
2+
import Unit from "../../TowerComponents/Unit.js";
23

34
const ViewerUtils = {
45
methods: {
@@ -98,7 +99,6 @@ const ViewerUtils = {
9899
if (this.unitManager.unitData[unitName]) {
99100
customUnits[unitName] = this.unitManager.unitData[unitName];
100101
} else {
101-
const Unit = require("../../TowerComponents/Unit.js").default;
102102
const newUnit = new Unit(unitName, unitData);
103103
this.unitManager.unitData[unitName] = newUnit;
104104
customUnits[unitName] = newUnit;

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)