ci: deploy on vercel again

This commit is contained in:
iCrawl
2023-11-08 13:27:04 +01:00
parent 2bda883a0f
commit 4575e49ea1
13 changed files with 33 additions and 80 deletions

View File

@@ -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;
}
});