fix: handle optional metadata in getInstallExtras for improved extension installation

This commit is contained in:
Huakun Shen 2025-01-12 04:01:05 -05:00
parent 7e811440b8
commit f78403eeb6
2 changed files with 6 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@kksh/desktop",
"version": "0.1.14",
"version": "0.1.15",
"description": "",
"type": "module",
"scripts": {

View File

@ -2,13 +2,13 @@ import type { Tables } from "@kksh/api/supabase/types"
import type { ExtPublishMetadata } from "@kksh/supabase/models"
export async function getInstallExtras(
ext: Tables<"ext_publish"> & { metadata: ExtPublishMetadata }
ext: Tables<"ext_publish"> & { metadata?: ExtPublishMetadata }
): Promise<{ overwritePackageJson?: string }> {
const extras: { overwritePackageJson?: string } = {}
if (ext.metadata.sourceType) {
if (ext.metadata.sourceType === "jsr") {
if (ext.metadata.source) {
try {
if (ext.metadata?.sourceType) {
if (ext.metadata?.sourceType === "jsr") {
if (ext.metadata?.source) {
try {
const res = await fetch(`${ext.metadata.source}/package.json`)
const pkgJsonContent = await res.text()
extras.overwritePackageJson = pkgJsonContent