- Replace all references to "Kettu" with "ShiggyCord" in code, UI, and docs - Update icons and assets to use shiggy.png - Change repo URLs to GitHub ShiggyCord repository - Update build output to shiggycord.js - Remove Codeberg and legacy workflow/config files - Add new GitHub release workflow and semantic-release config - Update i18n strings and debug info to reflect ShiggyCord branding - Refactor settings, plugin, and theme pages for new branding and improved UX - Add FixEmbed and MessageFix core plugins - Refactor NoTrack plugin for improved telemetry blocking - Remove unused PluginBrowser page - Miscellaneous code style and formatting improvements
55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
// @ts-nocheck
|
|
import chalk from "chalk";
|
|
import { readFile } from "fs/promises";
|
|
import http from "http";
|
|
import os from "os";
|
|
import readline from "readline";
|
|
import url from "url";
|
|
import yargs from "yargs-parser";
|
|
|
|
import { buildBundle } from "./build.mjs";
|
|
import { printBuildSuccess } from "./util.mjs";
|
|
|
|
const args = yargs(process.argv.slice(2));
|
|
|
|
export function serve(options) {
|
|
// @ts-ignore
|
|
const server = http.createServer(async (req, res) => {
|
|
const { pathname } = url.parse(req.url || "", true);
|
|
if (pathname?.endsWith(".js")) {
|
|
try {
|
|
const { config, context, timeTook } = await buildBundle();
|
|
|
|
printBuildSuccess(context.hash, args.production, timeTook);
|
|
|
|
res.writeHead(200, { "Content-Type": "application/javascript" });
|
|
res.end(await readFile(config.outfile, "utf-8"));
|
|
} catch {
|
|
res.writeHead(500);
|
|
res.end();
|
|
}
|
|
} else {
|
|
res.writeHead(404);
|
|
res.end();
|
|
}
|
|
}, options);
|
|
|
|
server.listen(args.port ?? 4040);
|
|
|
|
console.info(chalk.bold.yellowBright("Serving ShiggyCord on:"));
|
|
|
|
const netInterfaces = os.networkInterfaces();
|
|
for (const netinterfaces of Object.values(netInterfaces)) {
|
|
for (const details of netinterfaces || []) {
|
|
if (details.family !== "IPv4") continue;
|
|
const port = chalk.green(server.address()?.port.toString());
|
|
console.info(` http://${details.address}:${port}/shiggycord.js`);
|
|
}
|
|
}
|
|
|
|
return server;
|
|
}
|
|
|
|
const server = serve();
|
|
|
|
console.log("\nPress Q key or Ctrl+C to exit.");
|