From 81a892e27f65fcbbf64a92cc3030d9a308670417 Mon Sep 17 00:00:00 2001 From: iCrawl Date: Mon, 13 Nov 2023 19:13:32 +0100 Subject: [PATCH] fix: properly create index --- apps/website/scripts/generateAllIndices.js | 6 +----- packages/actions/src/uploadSearchIndices/index.ts | 3 ++- packages/scripts/package.json | 2 +- packages/scripts/src/generateIndex.ts | 2 +- packages/scripts/src/populateDevDatabaseBranch.ts | 3 --- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/apps/website/scripts/generateAllIndices.js b/apps/website/scripts/generateAllIndices.js index b60115cb5..baf0f1692 100644 --- a/apps/website/scripts/generateAllIndices.js +++ b/apps/website/scripts/generateAllIndices.js @@ -3,13 +3,9 @@ import { generateAllIndices } from '@discordjs/scripts'; console.log('Generating all indices...'); await generateAllIndices({ - fetchPackageVersions: async (pkg) => { - console.log(`Fetching versions for ${pkg}...`); - return ['main']; - }, fetchPackageVersionDocs: async (pkg, version) => { console.log(`Fetching data for ${pkg} ${version}...`); - return JSON.parse(await readFile(`${process.cwd()}/../../packages/${pkg}/docs/docs.api.json`, 'utf8')); + return JSON.parse(await readFile(`${process.cwd()}/../../../docs/${pkg}/${version}.api.json`, 'utf8')); }, }); console.log('Generated all indices.'); diff --git a/packages/actions/src/uploadSearchIndices/index.ts b/packages/actions/src/uploadSearchIndices/index.ts index 9755196a1..76b0f5cbc 100644 --- a/packages/actions/src/uploadSearchIndices/index.ts +++ b/packages/actions/src/uploadSearchIndices/index.ts @@ -57,7 +57,8 @@ try { await Promise.all( indices.map(async (index) => { console.log(`Uploading ${index.index}...`); - return client.index(index.index).addDocuments(index.data); + await client.createIndex(index.index); + await client.index(index.index).addDocuments(index.data); }), ); } catch {} diff --git a/packages/scripts/package.json b/packages/scripts/package.json index d091b84d8..7da2b11b4 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -5,7 +5,7 @@ "description": "A set of scripts that we use for our workflows", "private": true, "scripts": { - "build": "tsc --noEmit && tsup", + "build": "tsc --noEmit --lib ESNext,DOM && tsup", "lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src turbo/generators/config.ts", "format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src turbo/generators/config.ts", "fmt": "pnpm run format" diff --git a/packages/scripts/src/generateIndex.ts b/packages/scripts/src/generateIndex.ts index 7bc688ce0..0613d12dc 100644 --- a/packages/scripts/src/generateIndex.ts +++ b/packages/scripts/src/generateIndex.ts @@ -166,7 +166,7 @@ export async function generateAllIndices({ fetchPackageVersions = fetchVersions, fetchPackageVersionDocs = fetchVersionDocs, writeToFile = true, -}) { +} = {}) { const indices: Record[] = []; for (const pkg of PACKAGES) { diff --git a/packages/scripts/src/populateDevDatabaseBranch.ts b/packages/scripts/src/populateDevDatabaseBranch.ts index 547b45302..de48b654e 100644 --- a/packages/scripts/src/populateDevDatabaseBranch.ts +++ b/packages/scripts/src/populateDevDatabaseBranch.ts @@ -1,6 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/triple-slash-reference -/// - import { readFile } from 'node:fs/promises'; import process, { cwd } from 'node:process'; import { create } from '@actions/glob';