refactor: docs (#10126)

This commit is contained in:
Noel
2024-02-29 04:37:52 +01:00
committed by GitHub
parent 0f9017ef95
commit 18cce83d80
192 changed files with 8116 additions and 6321 deletions

View File

@@ -43,24 +43,24 @@
"@actions/core": "^1.10.1",
"@actions/glob": "^0.4.0",
"@discordjs/scripts": "workspace:^",
"@vercel/blob": "^0.20.0",
"@vercel/blob": "^0.22.1",
"@vercel/postgres": "^0.7.2",
"meilisearch": "^0.37.0",
"tslib": "^2.6.2",
"undici": "6.6.1"
"undici": "6.6.2"
},
"devDependencies": {
"@types/node": "18.18.8",
"@vitest/coverage-v8": "^1.2.2",
"@vitest/coverage-v8": "^1.3.1",
"cross-env": "^7.0.3",
"eslint": "^8.56.0",
"eslint-config-neon": "^0.1.58",
"eslint": "^8.57.0",
"eslint-config-neon": "^0.1.59",
"eslint-formatter-pretty": "^6.0.1",
"prettier": "^3.2.5",
"tsup": "^8.0.1",
"turbo": "^1.12.2",
"tsup": "^8.0.2",
"turbo": "^1.12.4",
"typescript": "^5.3.3",
"vitest": "^1.2.2"
"vitest": "^1.3.1"
},
"engines": {
"node": ">=18"

View File

@@ -52,10 +52,15 @@ try {
await Promise.all(
indices.map(async (index) => {
console.log(`Uploading ${index.index}...`);
let task;
try {
await client.createIndex(index.index);
task = await client.createIndex(index.index);
} catch {}
if (task) {
await client.waitForTask(task.taskUid);
}
await client.index(index.index).addDocuments(index.data);
}),
);

View File

@@ -1,33 +1,22 @@
import { readFile } from 'node:fs/promises';
import { basename } from 'node:path';
import process from 'node:process';
import { getInput, setFailed } from '@actions/core';
import { getInput } from '@actions/core';
import { create } from '@actions/glob';
import { put } from '@vercel/blob';
import { createPool } from '@vercel/postgres';
if (!process.env.DATABASE_URL) {
setFailed('DATABASE_URL is not set');
}
const pkg = getInput('package') || '*';
const version = getInput('version') || 'main';
const pool = createPool({
connectionString: process.env.DATABASE_URL,
});
const globber = await create(`packages/${pkg}/docs/split/main.*.*.api.json`);
const globber = await create(`packages/${pkg}/docs/${pkg}/split/*.api.json`);
for await (const file of globber.globGenerator()) {
const data = await readFile(file, 'utf8');
try {
console.log(`Uploading ${file} with ${version}...`);
const name = basename(file).replace('main.', '');
const { url } = await put(`${version}.${name}`, data, {
await put(`rewrite/${pkg}/${version}.${name}`, data, {
access: 'public',
addRandomSuffix: false,
});
await pool.sql`insert into documentation (name, version, url) values (${name}, ${version}, ${url}) on conflict (name, version) do update set url = EXCLUDED.url`;
} catch (error) {
console.log(error);
}

View File

@@ -2,11 +2,11 @@ import { createTsupConfig } from '../../tsup.config.js';
export default createTsupConfig({
entry: [
'src/buildSplitDocumentation/index.ts',
'src/index.ts',
'src/formatTag/index.ts',
'src/uploadDocumentation/index.ts',
'src/uploadSearchIndices/index.ts',
'src/uploadSplitDocumentation/index.ts',
],
dts: false,
format: 'esm',