mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-12-29 23:03:02 +05:00
Compare commits
No commits in common. "cbf08791120eddf9befbfc4978c3a79525fe2f0c" and "9f82e45a67f2bb9a2ed035a5cfef7df83242577a" have entirely different histories.
cbf0879112
...
9f82e45a67
11 changed files with 220 additions and 150 deletions
|
@ -1,9 +1,12 @@
|
|||
import { Client } from "discord.js";
|
||||
import { Client, Collection, REST, Routes } from "discord.js";
|
||||
import { config } from "../config.js";
|
||||
import { init as initCommands } from "../handlers/command-handler/index.js";
|
||||
import { init as initEvents } from "../handlers/event-handler/index.js";
|
||||
import { glob } from "glob";
|
||||
import { dirname } from "node:path";
|
||||
|
||||
export class ExtendedClient extends Client {
|
||||
commands = new Collection();
|
||||
__dirname = dirname(new URL(import.meta.url).pathname);
|
||||
rest = new REST().setToken(config.token);
|
||||
/**
|
||||
* @param {import("discord.js").ClientOptions} options
|
||||
*/
|
||||
|
@ -11,7 +14,44 @@ export class ExtendedClient extends Client {
|
|||
super(options);
|
||||
}
|
||||
|
||||
async init() {
|
||||
this.login(config.token).then(async () => await Promise.all([initCommands(), initEvents()]).catch(console.error));
|
||||
init() {
|
||||
this.registerModules();
|
||||
this.login(config.token);
|
||||
}
|
||||
|
||||
async importFile(filePath) {
|
||||
return (await import(`file://${filePath}`))?.default;
|
||||
}
|
||||
|
||||
async registerModules() {
|
||||
await this.registerCommands(this.__dirname);
|
||||
}
|
||||
|
||||
async registerCommands(baseDir) {
|
||||
const commandFiles = await glob(`${baseDir}/../newCommands/*/*.js`);
|
||||
const slashCommands = [];
|
||||
|
||||
for (const filePath of commandFiles) {
|
||||
try {
|
||||
const command = await this.importFile(filePath);
|
||||
if (!command.data.name) return;
|
||||
|
||||
this.commands.set(command.data.name, command);
|
||||
slashCommands.push(command.data.toJSON());
|
||||
} catch (error) {
|
||||
console.error(`Error loading command ${filePath}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
if (!slashCommands.length) return;
|
||||
|
||||
try {
|
||||
const route = config.production ? Routes.applicationCommands(config.userId) : Routes.applicationGuildCommands(config.userId, config.support.id);
|
||||
const data = await this.rest.put(route, { body: slashCommands });
|
||||
|
||||
console.log(`Successfully registered ${data.length} application commands.`);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
18
base/newCommand.js
Normal file
18
base/newCommand.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
export default class Command {
|
||||
constructor(options) {
|
||||
/**
|
||||
* @type {import("discord.js").ApplicationCommandData}
|
||||
*/
|
||||
this.data = options.data;
|
||||
/**
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.ownerOnly = !!options.ownerOnly || false;
|
||||
/**
|
||||
* @param {import("discord.js").CommandInteraction} [interaction]
|
||||
* @param {import('./newClient.js').ExtendedClient} [client]
|
||||
* @param {import("discord.js").CommandInteractionOptionResolver} [args]
|
||||
*/
|
||||
this.execute = function () {};
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
export default async function registerCommands(props) {
|
||||
const globalCommands = props.commands.filter(cmd => !cmd.options?.devOnly);
|
||||
await registerGlobalCommands(props.client, globalCommands);
|
||||
}
|
||||
|
||||
const registerGlobalCommands = async (client, commands) => {
|
||||
const appCommandsManager = client.application.commands;
|
||||
await appCommandsManager.fetch();
|
||||
|
||||
const newCommands = commands.filter(cmd => !appCommandsManager.cache.some(existingCmd => existingCmd.name === cmd.data.name));
|
||||
|
||||
await Promise.all(
|
||||
newCommands.map(data =>
|
||||
appCommandsManager.create(data).catch(() => {
|
||||
throw new Error(`Failed to register command: ${data.name}`);
|
||||
}),
|
||||
),
|
||||
);
|
||||
};
|
|
@ -1,35 +0,0 @@
|
|||
import { client } from "../../index.js";
|
||||
import { getFilePaths } from "../../utils/get-path.js";
|
||||
import { toFileURL } from "../../utils/resolve-file.js";
|
||||
import registerCommands from "./functions/registerCommands.js";
|
||||
|
||||
export const commands = [];
|
||||
|
||||
export const init = async () => {
|
||||
await buildCommands();
|
||||
|
||||
await registerCommands({
|
||||
client,
|
||||
commands,
|
||||
});
|
||||
};
|
||||
|
||||
const buildCommands = async () => {
|
||||
const commandFilePaths = (await getFilePaths("./newCommands", true)).filter(path => path.endsWith(".js"));
|
||||
|
||||
for (const cmdFilePath of commandFilePaths) {
|
||||
const { data, run } = await import(toFileURL(cmdFilePath));
|
||||
|
||||
if (!data || !data.name) {
|
||||
console.warn(`Command ${cmdFilePath} does not have a data object or name`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof run !== "function") {
|
||||
console.warn(`Command ${cmdFilePath} does not have a run function or it is not a function`);
|
||||
continue;
|
||||
}
|
||||
|
||||
commands.push({ data, run });
|
||||
}
|
||||
};
|
|
@ -1,41 +0,0 @@
|
|||
import { client } from "../../index.js";
|
||||
import { getFilePaths } from "../../utils/get-path.js";
|
||||
import { toFileURL } from "../../utils/resolve-file.js";
|
||||
|
||||
export const events = [];
|
||||
|
||||
export const init = async () => {
|
||||
await buildEvents();
|
||||
|
||||
registerEvents();
|
||||
};
|
||||
|
||||
const buildEvents = async () => {
|
||||
const eventFilePaths = (await getFilePaths("./newEvents", true)).filter(path => path.endsWith(".js"));
|
||||
|
||||
for (const eventFilePath of eventFilePaths) {
|
||||
const { data, run } = await import(toFileURL(eventFilePath));
|
||||
|
||||
if (!data || !data.name) {
|
||||
console.warn(`Event ${eventFilePath} does not have a data object or name`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof run !== "function") {
|
||||
console.warn(`Event ${eventFilePath} does not have a run function or it is not a function`);
|
||||
continue;
|
||||
}
|
||||
|
||||
events.push({ data, run });
|
||||
}
|
||||
};
|
||||
|
||||
const registerEvents = () => {
|
||||
for (const { data, run } of events) {
|
||||
if (data.once) {
|
||||
client.once(data.name, run);
|
||||
} else {
|
||||
client.on(data.name, run);
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,8 +1,10 @@
|
|||
export const data = {
|
||||
name: "8ball",
|
||||
description: "8ball",
|
||||
};
|
||||
import { SlashCommandBuilder } from "discord.js";
|
||||
import Command from "../../base/newCommand.js";
|
||||
|
||||
export const run = () => {
|
||||
console.log("8ball");
|
||||
};
|
||||
export default new Command({
|
||||
data: new SlashCommandBuilder().setName("8ball").setDescription("8ball"),
|
||||
execute(interaction) {
|
||||
console.log("8ball");
|
||||
interaction.reply("8ball");
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
export const data = {
|
||||
name: "ready",
|
||||
once: true,
|
||||
};
|
||||
|
||||
export async function run(client) {
|
||||
console.log(client.user.tag + " is online!");
|
||||
}
|
|
@ -22,6 +22,7 @@
|
|||
"discord-player-youtubei": "1.3.5",
|
||||
"discord.js": "^14.16.3",
|
||||
"gamedig": "^5.1.4",
|
||||
"glob": "^11.0.0",
|
||||
"i18next": "^24.0.0",
|
||||
"i18next-fs-backend": "^2.6.0",
|
||||
"md5": "^2.3.0",
|
||||
|
|
147
pnpm-lock.yaml
147
pnpm-lock.yaml
|
@ -47,6 +47,9 @@ importers:
|
|||
gamedig:
|
||||
specifier: ^5.1.4
|
||||
version: 5.1.4
|
||||
glob:
|
||||
specifier: ^11.0.0
|
||||
version: 11.0.0
|
||||
i18next:
|
||||
specifier: ^24.0.0
|
||||
version: 24.0.0(typescript@5.7.2)
|
||||
|
@ -227,6 +230,10 @@ packages:
|
|||
resolution: {integrity: sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA==}
|
||||
engines: {node: '>=18.18'}
|
||||
|
||||
'@isaacs/cliui@8.0.2':
|
||||
resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
'@jest/schemas@29.6.3':
|
||||
resolution: {integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
|
@ -441,6 +448,10 @@ packages:
|
|||
resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
ansi-regex@6.1.0:
|
||||
resolution: {integrity: sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
ansi-styles@2.2.1:
|
||||
resolution: {integrity: sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
@ -453,6 +464,10 @@ packages:
|
|||
resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
ansi-styles@6.2.1:
|
||||
resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
any-promise@1.3.0:
|
||||
resolution: {integrity: sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==}
|
||||
|
||||
|
@ -667,9 +682,15 @@ packages:
|
|||
domutils@3.1.0:
|
||||
resolution: {integrity: sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==}
|
||||
|
||||
eastasianwidth@0.2.0:
|
||||
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
|
||||
|
||||
emoji-regex@8.0.0:
|
||||
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
|
||||
|
||||
emoji-regex@9.2.2:
|
||||
resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==}
|
||||
|
||||
entities@4.5.0:
|
||||
resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
|
||||
engines: {node: '>=0.12'}
|
||||
|
@ -793,6 +814,10 @@ packages:
|
|||
flatted@3.3.1:
|
||||
resolution: {integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==}
|
||||
|
||||
foreground-child@3.3.0:
|
||||
resolution: {integrity: sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
form-data-encoder@2.1.4:
|
||||
resolution: {integrity: sha512-yDYSgNMraqvnxiEXO4hi88+YZxaHC6QKzb5N84iRCTDeRO7ZALpir/lVmf/uXUhnwUr2O4HU8s/n6x+yNjQkHw==}
|
||||
engines: {node: '>= 14.17'}
|
||||
|
@ -837,6 +862,11 @@ packages:
|
|||
resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
|
||||
glob@11.0.0:
|
||||
resolution: {integrity: sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==}
|
||||
engines: {node: 20 || >=22}
|
||||
hasBin: true
|
||||
|
||||
glob@7.2.3:
|
||||
resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==}
|
||||
deprecated: Glob versions prior to v9 are no longer supported
|
||||
|
@ -976,6 +1006,10 @@ packages:
|
|||
isomorphic-unfetch@4.0.2:
|
||||
resolution: {integrity: sha512-1Yd+CF/7al18/N2BDbsLBcp6RO3tucSW+jcLq24dqdX5MNbCNTw1z4BsGsp4zNmjr/Izm2cs/cEqZPp4kvWSCA==}
|
||||
|
||||
jackspeak@4.0.2:
|
||||
resolution: {integrity: sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==}
|
||||
engines: {node: 20 || >=22}
|
||||
|
||||
jintr@3.0.2:
|
||||
resolution: {integrity: sha512-5g2EBudeJFOopjAX4exAv5OCCW1DgUISfoioCsm1h9Q9HJ41LmnZ6J52PCsqBlQihsmp0VDuxreAVzM7yk5nFA==}
|
||||
|
||||
|
@ -1039,6 +1073,10 @@ packages:
|
|||
resolution: {integrity: sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
|
||||
lru-cache@11.0.2:
|
||||
resolution: {integrity: sha512-123qHRfJBmo2jXDbo/a5YOQrJoHF/GNQTLzQ5+IdK5pWpceK17yRc6ozlWd25FxvGKQbIUs91fDFkXmDHTKcyA==}
|
||||
engines: {node: 20 || >=22}
|
||||
|
||||
luxon@3.5.0:
|
||||
resolution: {integrity: sha512-rh+Zjr6DNfUYR3bPwJEnuwDdqMbxZW7LOQfUN4B54+Cl+0o5zaU9RJ6bcidfDtC1cWCZXQ+nvX8bf6bAji37QQ==}
|
||||
engines: {node: '>=12'}
|
||||
|
@ -1072,6 +1110,10 @@ packages:
|
|||
resolution: {integrity: sha512-e5ISH9xMYU0DzrT+jl8q2ze9D6eWBto+I8CNpe+VI+K2J/F/k3PdkdTdz4wvGVH4NTpo+NRYTVIuMQEMMcsLqg==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
|
||||
minimatch@10.0.1:
|
||||
resolution: {integrity: sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==}
|
||||
engines: {node: 20 || >=22}
|
||||
|
||||
minimatch@3.1.2:
|
||||
resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==}
|
||||
|
||||
|
@ -1090,6 +1132,10 @@ packages:
|
|||
resolution: {integrity: sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
minipass@7.1.2:
|
||||
resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==}
|
||||
engines: {node: '>=16 || 14 >=14.17'}
|
||||
|
||||
minizlib@2.1.2:
|
||||
resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==}
|
||||
engines: {node: '>= 8'}
|
||||
|
@ -1212,6 +1258,9 @@ packages:
|
|||
resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
package-json-from-dist@1.0.1:
|
||||
resolution: {integrity: sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==}
|
||||
|
||||
parent-module@1.0.1:
|
||||
resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==}
|
||||
engines: {node: '>=6'}
|
||||
|
@ -1234,6 +1283,10 @@ packages:
|
|||
resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
path-scurry@2.0.0:
|
||||
resolution: {integrity: sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==}
|
||||
engines: {node: 20 || >=22}
|
||||
|
||||
path-type@4.0.0:
|
||||
resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==}
|
||||
engines: {node: '>=8'}
|
||||
|
@ -1399,6 +1452,10 @@ packages:
|
|||
signal-exit@3.0.7:
|
||||
resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==}
|
||||
|
||||
signal-exit@4.1.0:
|
||||
resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
slash@3.0.0:
|
||||
resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==}
|
||||
engines: {node: '>=8'}
|
||||
|
@ -1435,6 +1492,10 @@ packages:
|
|||
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
string-width@5.1.2:
|
||||
resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
string_decoder@0.10.31:
|
||||
resolution: {integrity: sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==}
|
||||
|
||||
|
@ -1452,6 +1513,10 @@ packages:
|
|||
resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
strip-ansi@7.1.0:
|
||||
resolution: {integrity: sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
strip-json-comments@3.1.1:
|
||||
resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==}
|
||||
engines: {node: '>=8'}
|
||||
|
@ -1581,6 +1646,14 @@ packages:
|
|||
resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
wrap-ansi@7.0.0:
|
||||
resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
wrap-ansi@8.1.0:
|
||||
resolution: {integrity: sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
wrappy@1.0.2:
|
||||
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
|
||||
|
||||
|
@ -1820,6 +1893,15 @@ snapshots:
|
|||
|
||||
'@humanwhocodes/retry@0.4.1': {}
|
||||
|
||||
'@isaacs/cliui@8.0.2':
|
||||
dependencies:
|
||||
string-width: 5.1.2
|
||||
string-width-cjs: string-width@4.2.3
|
||||
strip-ansi: 7.1.0
|
||||
strip-ansi-cjs: strip-ansi@6.0.1
|
||||
wrap-ansi: 8.1.0
|
||||
wrap-ansi-cjs: wrap-ansi@7.0.0
|
||||
|
||||
'@jest/schemas@29.6.3':
|
||||
dependencies:
|
||||
'@sinclair/typebox': 0.27.8
|
||||
|
@ -2003,6 +2085,8 @@ snapshots:
|
|||
|
||||
ansi-regex@5.0.1: {}
|
||||
|
||||
ansi-regex@6.1.0: {}
|
||||
|
||||
ansi-styles@2.2.1: {}
|
||||
|
||||
ansi-styles@4.3.0:
|
||||
|
@ -2011,6 +2095,8 @@ snapshots:
|
|||
|
||||
ansi-styles@5.2.0: {}
|
||||
|
||||
ansi-styles@6.2.1: {}
|
||||
|
||||
any-promise@1.3.0: {}
|
||||
|
||||
aproba@2.0.0: {}
|
||||
|
@ -2258,8 +2344,12 @@ snapshots:
|
|||
domelementtype: 2.3.0
|
||||
domhandler: 5.0.3
|
||||
|
||||
eastasianwidth@0.2.0: {}
|
||||
|
||||
emoji-regex@8.0.0: {}
|
||||
|
||||
emoji-regex@9.2.2: {}
|
||||
|
||||
entities@4.5.0: {}
|
||||
|
||||
escape-string-regexp@1.0.5: {}
|
||||
|
@ -2447,6 +2537,11 @@ snapshots:
|
|||
|
||||
flatted@3.3.1: {}
|
||||
|
||||
foreground-child@3.3.0:
|
||||
dependencies:
|
||||
cross-spawn: 7.0.6
|
||||
signal-exit: 4.1.0
|
||||
|
||||
form-data-encoder@2.1.4: {}
|
||||
|
||||
formdata-polyfill@4.0.10:
|
||||
|
@ -2505,6 +2600,15 @@ snapshots:
|
|||
dependencies:
|
||||
is-glob: 4.0.3
|
||||
|
||||
glob@11.0.0:
|
||||
dependencies:
|
||||
foreground-child: 3.3.0
|
||||
jackspeak: 4.0.2
|
||||
minimatch: 10.0.1
|
||||
minipass: 7.1.2
|
||||
package-json-from-dist: 1.0.1
|
||||
path-scurry: 2.0.0
|
||||
|
||||
glob@7.2.3:
|
||||
dependencies:
|
||||
fs.realpath: 1.0.0
|
||||
|
@ -2643,6 +2747,10 @@ snapshots:
|
|||
node-fetch: 3.3.2
|
||||
unfetch: 5.0.0
|
||||
|
||||
jackspeak@4.0.2:
|
||||
dependencies:
|
||||
'@isaacs/cliui': 8.0.2
|
||||
|
||||
jintr@3.0.2:
|
||||
dependencies:
|
||||
acorn: 8.12.1
|
||||
|
@ -2698,6 +2806,8 @@ snapshots:
|
|||
|
||||
lowercase-keys@3.0.0: {}
|
||||
|
||||
lru-cache@11.0.2: {}
|
||||
|
||||
luxon@3.5.0: {}
|
||||
|
||||
magic-bytes.js@1.10.0: {}
|
||||
|
@ -2725,6 +2835,10 @@ snapshots:
|
|||
|
||||
mimic-response@4.0.0: {}
|
||||
|
||||
minimatch@10.0.1:
|
||||
dependencies:
|
||||
brace-expansion: 2.0.1
|
||||
|
||||
minimatch@3.1.2:
|
||||
dependencies:
|
||||
brace-expansion: 1.1.11
|
||||
|
@ -2741,6 +2855,8 @@ snapshots:
|
|||
|
||||
minipass@5.0.0: {}
|
||||
|
||||
minipass@7.1.2: {}
|
||||
|
||||
minizlib@2.1.2:
|
||||
dependencies:
|
||||
minipass: 3.3.6
|
||||
|
@ -2855,6 +2971,8 @@ snapshots:
|
|||
dependencies:
|
||||
p-limit: 3.1.0
|
||||
|
||||
package-json-from-dist@1.0.1: {}
|
||||
|
||||
parent-module@1.0.1:
|
||||
dependencies:
|
||||
callsites: 3.1.0
|
||||
|
@ -2874,6 +2992,11 @@ snapshots:
|
|||
|
||||
path-key@3.1.1: {}
|
||||
|
||||
path-scurry@2.0.0:
|
||||
dependencies:
|
||||
lru-cache: 11.0.2
|
||||
minipass: 7.1.2
|
||||
|
||||
path-type@4.0.0: {}
|
||||
|
||||
peek-readable@4.1.0: {}
|
||||
|
@ -3012,6 +3135,8 @@ snapshots:
|
|||
|
||||
signal-exit@3.0.7: {}
|
||||
|
||||
signal-exit@4.1.0: {}
|
||||
|
||||
slash@3.0.0: {}
|
||||
|
||||
smart-buffer@4.2.0:
|
||||
|
@ -3052,6 +3177,12 @@ snapshots:
|
|||
is-fullwidth-code-point: 3.0.0
|
||||
strip-ansi: 6.0.1
|
||||
|
||||
string-width@5.1.2:
|
||||
dependencies:
|
||||
eastasianwidth: 0.2.0
|
||||
emoji-regex: 9.2.2
|
||||
strip-ansi: 7.1.0
|
||||
|
||||
string_decoder@0.10.31: {}
|
||||
|
||||
string_decoder@1.1.1:
|
||||
|
@ -3070,6 +3201,10 @@ snapshots:
|
|||
dependencies:
|
||||
ansi-regex: 5.0.1
|
||||
|
||||
strip-ansi@7.1.0:
|
||||
dependencies:
|
||||
ansi-regex: 6.1.0
|
||||
|
||||
strip-json-comments@3.1.1: {}
|
||||
|
||||
strtok3@6.3.0:
|
||||
|
@ -3186,6 +3321,18 @@ snapshots:
|
|||
|
||||
word-wrap@1.2.5: {}
|
||||
|
||||
wrap-ansi@7.0.0:
|
||||
dependencies:
|
||||
ansi-styles: 4.3.0
|
||||
string-width: 4.2.3
|
||||
strip-ansi: 6.0.1
|
||||
|
||||
wrap-ansi@8.1.0:
|
||||
dependencies:
|
||||
ansi-styles: 6.2.1
|
||||
string-width: 5.1.2
|
||||
strip-ansi: 7.1.0
|
||||
|
||||
wrappy@1.0.2: {}
|
||||
|
||||
ws@8.18.0: {}
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
export const getFilePaths = async (directory, nesting) => {
|
||||
let filePaths = [];
|
||||
|
||||
if (!directory) return;
|
||||
|
||||
const files = await fs.readdir(directory, { withFileTypes: true });
|
||||
|
||||
for (const file of files) {
|
||||
const filePath = path.join(directory, file.name);
|
||||
|
||||
if (file.isFile()) {
|
||||
filePaths.push(filePath);
|
||||
}
|
||||
|
||||
if (nesting && file.isDirectory()) {
|
||||
filePaths = [...filePaths, ...(await getFilePaths(filePath, true))];
|
||||
}
|
||||
}
|
||||
|
||||
return filePaths;
|
||||
};
|
|
@ -1,11 +0,0 @@
|
|||
import path from "node:path";
|
||||
|
||||
/**
|
||||
* Convert a local file path to a file URL.
|
||||
* @param {string} filePath - local file's path.
|
||||
* @returns {string} file URL
|
||||
*/
|
||||
export const toFileURL = filePath => {
|
||||
const resolvedPath = path.resolve(filePath);
|
||||
return "file://" + resolvedPath.replace(/\\\\|\\/g, "/");
|
||||
};
|
Loading…
Reference in a new issue