mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
chore: update deps & search indice action refactor (#11339)
* chore: update deps & search indice action refactor - Updated pnpm, dependencies and regenerated the lockfile - Removed immer and some eslint plugins that weren't being used - Updated the version of `@types/node` to v24 on internal packages as that's the version that is being used on github actions - Refactored the uploadSearchIndices action slightly and upgraded the meilisearch dependency * chore: remove more deps
This commit is contained in:
@@ -48,7 +48,7 @@
|
||||
"@discordjs/scripts": "workspace:^",
|
||||
"cloudflare": "^5.2.0",
|
||||
"commander": "^14.0.2",
|
||||
"meilisearch": "^0.38.0",
|
||||
"meilisearch": "^0.54.0",
|
||||
"p-limit": "^7.2.0",
|
||||
"p-queue": "^9.0.1",
|
||||
"tslib": "^2.8.1",
|
||||
@@ -56,8 +56,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@npm/types": "^2.1.0",
|
||||
"@types/bun": "^1.3.3",
|
||||
"@types/node": "^22.19.1",
|
||||
"@types/bun": "^1.3.4",
|
||||
"@types/node": "^24.10.1",
|
||||
"@vitest/coverage-v8": "^4.0.15",
|
||||
"cross-env": "^10.1.0",
|
||||
"eslint": "^9.39.1",
|
||||
|
||||
@@ -2,33 +2,35 @@ import process from 'node:process';
|
||||
import { setFailed } from '@actions/core';
|
||||
import { generateAllIndices } from '@discordjs/scripts';
|
||||
import Cloudflare from 'cloudflare';
|
||||
import { MeiliSearch } from 'meilisearch';
|
||||
import { type EnqueuedTask, MeiliSearch } from 'meilisearch';
|
||||
import pLimit from 'p-limit';
|
||||
import { fetch } from 'undici';
|
||||
|
||||
if (!(process.env.CF_D1_DOCS_API_KEY && process.env.CF_D1_DOCS_ID && process.env.CF_ACCOUNT_ID)) {
|
||||
if (!process.env.CF_D1_DOCS_API_KEY || !process.env.CF_D1_DOCS_ID || !process.env.CF_ACCOUNT_ID) {
|
||||
setFailed('Missing Cloudflare D1 environment variables.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!process.env.SEARCH_API_URL) {
|
||||
setFailed('SEARCH_API_URL is not set');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!process.env.SEARCH_API_KEY) {
|
||||
setFailed('SEARCH_API_KEY is not set');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const cf = new Cloudflare({
|
||||
apiToken: process.env.CF_D1_DOCS_API_KEY!,
|
||||
apiToken: process.env.CF_D1_DOCS_API_KEY,
|
||||
});
|
||||
|
||||
const client = new MeiliSearch({
|
||||
host: process.env.SEARCH_API_URL!,
|
||||
apiKey: process.env.SEARCH_API_KEY!,
|
||||
host: process.env.SEARCH_API_URL,
|
||||
apiKey: process.env.SEARCH_API_KEY,
|
||||
});
|
||||
|
||||
const limit = pLimit(10);
|
||||
let promises: Promise<any>[] = [];
|
||||
|
||||
try {
|
||||
console.log('Generating all indices...');
|
||||
@@ -62,35 +64,31 @@ try {
|
||||
|
||||
console.log('Uploading indices...');
|
||||
|
||||
try {
|
||||
promises = indices.map(async (index) =>
|
||||
limit(async () => {
|
||||
console.log(`Uploading ${index.index}...`);
|
||||
let task;
|
||||
try {
|
||||
task = await client.createIndex(index.index);
|
||||
} catch {}
|
||||
const promises = indices.map(async (index) =>
|
||||
limit(async () => {
|
||||
console.log(`Uploading ${index.index}...`);
|
||||
let task: EnqueuedTask | undefined;
|
||||
try {
|
||||
task = await client.createIndex(index.index);
|
||||
} catch {}
|
||||
|
||||
if (task) {
|
||||
await client.waitForTask(task.taskUid);
|
||||
}
|
||||
if (task) {
|
||||
await client.tasks.waitForTask(task);
|
||||
}
|
||||
|
||||
const searchIndex = client.index(index.index);
|
||||
await searchIndex.updateSettings({ sortableAttributes: ['type'] });
|
||||
const searchIndex = client.index(index.index);
|
||||
await searchIndex.updateSettings({ sortableAttributes: ['type'] });
|
||||
|
||||
await searchIndex.addDocuments(index.data);
|
||||
}),
|
||||
);
|
||||
} catch {}
|
||||
await searchIndex.addDocuments(index.data);
|
||||
}),
|
||||
);
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
console.log('Uploaded all indices.');
|
||||
} catch (error) {
|
||||
const err = error as Error;
|
||||
console.error(err);
|
||||
setFailed(err.message);
|
||||
}
|
||||
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user