mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-21 17:14:43 +12:00
ci: deploy on vercel again
This commit is contained in:
parent
2bda883a0f
commit
4575e49ea1
13 changed files with 33 additions and 80 deletions
25
.github/workflows/deploy-website.yml
vendored
25
.github/workflows/deploy-website.yml
vendored
|
@ -8,35 +8,11 @@ jobs:
|
|||
deploy-website:
|
||||
name: Deploy website
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
||||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
||||
if: github.repository_owner == 'discordjs'
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./packages/actions/src/pnpmCache
|
||||
|
||||
- name: Build dependencies
|
||||
run: pnpm run build
|
||||
|
||||
- name: Cache .next/cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
${{ github.workspace }}/.next/cache
|
||||
key: ${{ runner.os }}-nextjs-${{ hashFiles('apps/website/**/*.ts', 'apps/website/**/*.tsx') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-nextjs-
|
||||
|
||||
- name: Pull vercel production environment
|
||||
run: pnpm exec vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
|
||||
|
||||
- name: Build website artifacts
|
||||
run: pnpm exec vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
|
||||
|
||||
- name: Build & deploy website
|
||||
uses: BetaHuhn/deploy-to-vercel-action@643bc80032ba62ca41d1a9aaba7b38b51c2b8646
|
||||
with:
|
||||
|
@ -47,4 +23,3 @@ jobs:
|
|||
VERCEL_SCOPE: 'discordjs'
|
||||
GITHUB_DEPLOYMENT_ENV: 'Production – discord-js'
|
||||
PRODUCTION: true
|
||||
PREBUILT: true
|
||||
|
|
25
.github/workflows/documentation.yml
vendored
25
.github/workflows/documentation.yml
vendored
|
@ -157,35 +157,11 @@ jobs:
|
|||
needs: build-docs
|
||||
name: Deploy website
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
||||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
||||
if: github.repository_owner == 'discordjs'
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./packages/actions/src/pnpmCache
|
||||
|
||||
- name: Build dependencies
|
||||
run: pnpm run build
|
||||
|
||||
- name: Cache .next/cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
${{ github.workspace }}/.next/cache
|
||||
key: ${{ runner.os }}-nextjs-${{ hashFiles('apps/website/**/*.ts', 'apps/website/**/*.tsx') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-nextjs-
|
||||
|
||||
- name: Pull vercel production environment
|
||||
run: pnpm exec vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
|
||||
|
||||
- name: Build website artifacts
|
||||
run: pnpm exec vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
|
||||
|
||||
- name: Build & deploy website
|
||||
uses: BetaHuhn/deploy-to-vercel-action@643bc80032ba62ca41d1a9aaba7b38b51c2b8646
|
||||
with:
|
||||
|
@ -196,4 +172,3 @@ jobs:
|
|||
VERCEL_SCOPE: 'discordjs'
|
||||
GITHUB_DEPLOYMENT_ENV: 'Production – discord-js'
|
||||
PRODUCTION: true
|
||||
PREBUILT: true
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { readFile } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { connect } from '@planetscale/database';
|
||||
import { cache } from 'react';
|
||||
import { N_RECENT_VERSIONS } from '~/util/constants';
|
||||
|
||||
const sql = connect({
|
||||
|
@ -11,7 +12,7 @@ const sql = connect({
|
|||
},
|
||||
});
|
||||
|
||||
export async function fetchVersions(packageName: string): Promise<string[]> {
|
||||
export const fetchVersions = cache(async (packageName: string) => {
|
||||
if (process.env.NEXT_PUBLIC_LOCAL_DEV || process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview') {
|
||||
return ['main'];
|
||||
}
|
||||
|
@ -22,9 +23,9 @@ export async function fetchVersions(packageName: string): Promise<string[]> {
|
|||
|
||||
// @ts-expect-error: https://github.com/planetscale/database-js/issues/71
|
||||
return rows.map((row) => row.version).slice(0, N_RECENT_VERSIONS);
|
||||
}
|
||||
});
|
||||
|
||||
export async function fetchModelJSON(packageName: string, version: string): Promise<unknown | null> {
|
||||
export const fetchModelJSON = cache(async (packageName: string, version: string) => {
|
||||
if (process.env.NEXT_PUBLIC_LOCAL_DEV) {
|
||||
let res;
|
||||
|
||||
|
@ -55,4 +56,4 @@ export async function fetchModelJSON(packageName: string, version: string): Prom
|
|||
|
||||
// @ts-expect-error: https://github.com/planetscale/database-js/issues/71
|
||||
return rows[0]?.data ?? null;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -26,10 +26,15 @@ import { Enum } from '~/components/model/enum/Enum';
|
|||
import { Function } from '~/components/model/function/Function';
|
||||
import { addPackageToModel } from '~/util/addPackageToModel';
|
||||
import { OVERLOAD_SEPARATOR } from '~/util/constants';
|
||||
import type { ItemRouteParams } from '~/util/fetchMember';
|
||||
import { fetchMember } from '~/util/fetchMember';
|
||||
import { findMember } from '~/util/model';
|
||||
|
||||
export interface ItemRouteParams {
|
||||
item: string;
|
||||
package: string;
|
||||
version: string;
|
||||
}
|
||||
|
||||
async function fetchHeadMember({ package: packageName, version, item }: ItemRouteParams) {
|
||||
const modelJSON = await fetchModelJSON(packageName, version);
|
||||
|
||||
|
@ -152,7 +157,7 @@ function Member({ member }: { readonly member?: ApiItem }) {
|
|||
}
|
||||
|
||||
export default async function Page({ params }: { params: ItemRouteParams }) {
|
||||
const member = await fetchMember(params);
|
||||
const member = await fetchMember(params.package, params.version ?? 'main', params.item);
|
||||
|
||||
if (!member) {
|
||||
notFound();
|
||||
|
|
|
@ -25,7 +25,7 @@ export async function generateStaticParams() {
|
|||
const params: VersionRouteParams[] = [];
|
||||
|
||||
await Promise.all(
|
||||
PACKAGES.map(async (packageName) => {
|
||||
PACKAGES.slice(1).map(async (packageName) => {
|
||||
const versions = await fetchVersions(packageName);
|
||||
|
||||
params.push(...versions.map((version) => ({ package: packageName, version })));
|
||||
|
|
|
@ -2,14 +2,15 @@ import { readFile } from 'node:fs/promises';
|
|||
import { join } from 'node:path';
|
||||
import type { SerializeOptions } from 'next-mdx-remote/dist/types';
|
||||
import { MDXRemote } from 'next-mdx-remote/rsc';
|
||||
import { cache } from 'react';
|
||||
import rehypeSlug from 'rehype-slug';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import { SyntaxHighlighter } from '~/components/SyntaxHighlighter';
|
||||
import type { VersionRouteParams } from './layout';
|
||||
|
||||
async function loadREADME(packageName: string) {
|
||||
const loadREADME = cache(async (packageName: string) => {
|
||||
return readFile(join(process.cwd(), 'src', 'assets', 'readme', packageName, 'home-README.md'), 'utf8');
|
||||
}
|
||||
});
|
||||
|
||||
const mdxOptions = {
|
||||
mdxOptions: {
|
||||
|
|
|
@ -2,8 +2,9 @@ import type { ApiModel, ApiPackage } from '@discordjs/api-extractor-model';
|
|||
import { ApiItem } from '@discordjs/api-extractor-model';
|
||||
import { TSDocConfiguration } from '@microsoft/tsdoc';
|
||||
import { TSDocConfigFile } from '@microsoft/tsdoc-config';
|
||||
import { cache } from 'react';
|
||||
|
||||
export function addPackageToModel(model: ApiModel, data: any) {
|
||||
export const addPackageToModel = cache((model: ApiModel, data: any) => {
|
||||
let apiPackage: ApiPackage;
|
||||
if (data.metadata) {
|
||||
const tsdocConfiguration = new TSDocConfiguration();
|
||||
|
@ -23,4 +24,4 @@ export function addPackageToModel(model: ApiModel, data: any) {
|
|||
|
||||
model.addMember(apiPackage);
|
||||
return model;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
import { ApiModel, ApiFunction } from '@discordjs/api-extractor-model';
|
||||
import { cache } from 'react';
|
||||
import { fetchModelJSON } from '~/app/docAPI';
|
||||
import { addPackageToModel } from './addPackageToModel';
|
||||
import { OVERLOAD_SEPARATOR, PACKAGES } from './constants';
|
||||
import { findMember, findMemberByKey } from './model';
|
||||
|
||||
export interface ItemRouteParams {
|
||||
item: string;
|
||||
package: string;
|
||||
version: string;
|
||||
}
|
||||
|
||||
export async function fetchMember({ package: packageName, version: branchName = 'main', item }: ItemRouteParams) {
|
||||
export const fetchMember = cache(async (packageName: string, branchName: string, item: string) => {
|
||||
if (!PACKAGES.includes(packageName)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -46,4 +41,4 @@ export async function fetchMember({ package: packageName, version: branchName =
|
|||
}
|
||||
|
||||
return memberName && containerKey ? findMemberByKey(model, packageName, containerKey) ?? null : null;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -6,20 +6,21 @@ import type {
|
|||
Excerpt,
|
||||
} from '@discordjs/api-extractor-model';
|
||||
import type { DocSection } from '@microsoft/tsdoc';
|
||||
import { cache } from 'react';
|
||||
|
||||
export function findMemberByKey(model: ApiModel, packageName: string, containerKey: string) {
|
||||
export const findMemberByKey = cache((model: ApiModel, packageName: string, containerKey: string) => {
|
||||
const pkg = model.tryGetPackageByName(packageName === 'discord.js' ? packageName : `@discordjs/${packageName}`)!;
|
||||
return (pkg.members[0] as ApiEntryPoint).tryGetMemberByKey(containerKey);
|
||||
}
|
||||
});
|
||||
|
||||
export function findMember(model: ApiModel, packageName: string, memberName: string | undefined) {
|
||||
export const findMember = cache((model: ApiModel, packageName: string, memberName: string | undefined) => {
|
||||
if (!memberName) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const pkg = model.tryGetPackageByName(packageName === 'discord.js' ? packageName : `@discordjs/${packageName}`)!;
|
||||
return pkg.entryPoints[0]?.findMembersByName(memberName)[0];
|
||||
}
|
||||
});
|
||||
|
||||
interface ResolvedParameter {
|
||||
description?: DocSection | undefined;
|
||||
|
|
|
@ -481,10 +481,9 @@ export function ApiItemContainerMixin<TBaseClass extends IApiItemConstructor>(
|
|||
const mappedTypeParameters: Map<string, string> = new Map();
|
||||
if (
|
||||
(apiItem.kind === ApiItemKind.Class || apiItem.kind === ApiItemKind.Interface) &&
|
||||
next.item.kind === ApiItemKind.Class &&
|
||||
extendsType.typeParameters?.length
|
||||
next.item.kind === ApiItemKind.Class
|
||||
) {
|
||||
for (const [index, typeParameter] of extendsType.typeParameters.entries()) {
|
||||
for (const [index, typeParameter] of extendsType.typeParameters?.entries() ?? []) {
|
||||
const key = (apiItem as ApiClass | ApiInterface).typeParameters[index]?.name ?? '';
|
||||
mappedTypeParameters.set(key, typeParameter);
|
||||
}
|
||||
|
|
|
@ -149,13 +149,13 @@ export class ApiClass extends ApiItemContainerMixin(
|
|||
if (this.extendsType) {
|
||||
jsonObject.extendsTokenRange = {
|
||||
...this.extendsType.excerpt.tokenRange,
|
||||
typeParameters: this.extendsType.typeParameters,
|
||||
typeParameters: this.extendsType.typeParameters ?? [],
|
||||
};
|
||||
}
|
||||
|
||||
jsonObject.implementsTokenRanges = this.implementsTypes.map((x) => ({
|
||||
...x.excerpt.tokenRange,
|
||||
typeParameters: x.typeParameters,
|
||||
typeParameters: x.typeParameters ?? [],
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ export class ApiInterface extends ApiItemContainerMixin(
|
|||
|
||||
jsonObject.extendsTokenRanges = this.extendsTypes.map((x) => ({
|
||||
...x.excerpt.tokenRange,
|
||||
typeParameters: x.typeParameters,
|
||||
typeParameters: x.typeParameters ?? [],
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ export class HeritageType {
|
|||
*/
|
||||
public readonly excerpt: Excerpt;
|
||||
|
||||
public readonly typeParameters: string[];
|
||||
public readonly typeParameters?: string[];
|
||||
|
||||
public constructor(excerpt: Excerpt, typeParameters: string[]) {
|
||||
this.excerpt = excerpt;
|
||||
|
|
Loading…
Reference in a new issue